Know How...

Aug 31st 2017

Know How... 341

IR Basics Part 1

Repurpose your old remote controls.
Although the show is no longer in production, you can enjoy episodes from the TWiT Archives.
Category: Help & How To

Basics of IR Control 

IR control is a BINARY communications system

  • It uses a series of "0" and "1" (off or on) to convey a value from a transmitter to a receiver
  • The "Transmitter" is an IR LED and the "Receiver is a photosensitive element that responds to IR light"
  • However... just being able to "see" if the IR LED is lit doesn't allow us to communicate.
  • We need to have a "protocol" that defines how long a "control sequence" is and how to read it.- In other words, I need to know when the sequence starts, and when it ends.

We're going to use the "IRremote" library which understands most of the POPULAR protocols 

Demo of Reading IR Codes

  1. Show Interface
  2. Show codes
  3. Show Hardware

Let's Assemble the hardware! 


  1. IR Receiver (AX-1838HS) and LED
  2. Arduino Nano 

Pinout of the IR Receiver

From left to right, looking at the front of the sensor

  1. Out
  2. GND
  3. VCC 

Let's Program! 

  • First, we need to include the "IRremote" Library
  • Sketch > Include Library > Manage Libraries 

#include <IRremote.h> // This is the library we need to speak IR protocols

#define IR_PIN 2 // The digital pin to which the IR Reciever is connected

IRrecv irrecv(IR_PIN); // Turn on the reciever
decode_results ircode; // Create a structure called "IRcode"

void setup()
Serial.begin(9600); // Start the Serial Port (for debug)
irrecv.enableIRIn(); // Start the receiver

void loop()
if (irrecv.decode(&ircode)) // IF the IR reciever has received a code, THEN run the following:
Serial.println(ircode.value, HEX); // Print the received code to the Serial Port (for Debug)
irrecv.resume(); // Wait for the next IR code


** This code is a basic IR code reader. It will receive an IR code from a remote, then print it to the serial console

Now that we know we can receive IR codes w/our Nano, let's DO something with it!


Code for this Episode can be found at the link below:

Connect with us!

Thanks to CacheFly for the bandwidth for this show.