IR Remote and Receiver

Using an IR Remote is a great way to have wireless control of your project.

Infrared remotes are simple and easy to use. In this tutorial we will be connecting the IR receiver to the UNO, and then use a Library that was designed for this particular sensor.

In our sketch we will have all the IR Hexadecimal codes that are available on this remote, we will also detect if the code was recognized and also if we are holding down a key.

Component Required:

1 x Uno R3

1x IR receiver module

1 x IR remote

3 x F-M wires (Female to Male DuPont wires)

IR RECEIVER SENSOR:

IR detectors are little microchips with a photocell that are tuned to listen to infrared light. They are almost always used for remote control detection - every TV and DVD player has one of these in the front to listen for the IR signal from the clicker. Inside the remote control is a matching IR LED, which emits IR pulses to tell the TV to turn on, off or change channels. IR light is not visible to the human eye, which means it takes a little more work to test a setup.

There are a few difference between these and say a CdS Photocells:

IR detectors are specially filtered for IR light, they are not good at detecting visible light. On the other hand, photocells are good at detecting yellow/green visible light, and are not good at IR light.

IR detectors have a demodulator inside that looks for modulated IR at 38 KHz. Just shining an IR LED won't be detected, it has to be PWM blinking at 38KHz. Photocells do not have any sort of demodulator and can detect any frequency (including DC) within the response speed of the photocell (which is about 1KHz)

IR detectors are digital out - either they detect 38KHz IR signal and output low (0V) or they do not detect any and output high (5V). Photocells act like resistors, the resistance changes depending on how much light they are exposed to.

What You Can Measure

As you can see from these datasheet graphs, the peak frequency detection is at 38 KHz and the peak LED color is 940 nm. You can use from about 35 KHz to 41 KHz but the sensitivity will drop off so that it won't detect as well from afar. Likewise, you can use 850 to 1100 nm LEDs but they won't work as well as 900 to 1000nm so make sure to get matching LEDs! Check the datasheet for your IR LED to verify the wavelength.

Try to get a 940nm - remember that 940nm is not visible light!

Connection Diagram:

Wiring schematic

There are 3 connections to the IR Receiver.

The connections are: Signal, Voltage and Ground.

The “-” is the Ground, “S” is signal, and middle pin is Voltage 5V.

Physical wiring diagram:

Code

After wiring, install the IRRemote.zip library

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); //Initialize infrared remote control
  pinMode(13,OUTPUT);
}

void loop() {
if (irrecv.decode(&results))
{
  if(results.value==16753245)   //Confirm the code of the first row of keys 1 received. //This code is the code of the keys read in advance.  {
  digitalWrite(13,1);                //Light up the LED
  Serial.println("turn on LED"); //Serial port display lights on
  }
 //Confirm the code for the first row of keys 2 received
  else if(results.value==16736925)  {
    digitalWrite(13,0);            //Put out the LED
    Serial.println("turn off LED");    //Serial port displays lights off
  }
    irrecv.resume(); // Receive the next value
  
}

Open the serial monitor as follows:

Last updated