Arduino Universal IR Remote Control

5,014 views

An IR Remote control is a line-of-sight-based wireless communication device that works in tandem with an IR Receiver. Here we design it by using Arduino and IR receiver TSOP 1738, you can use any IR receiver available. We can decode any infrared remote code into hex or some other format. Always follow the datasheet of the IR receiver before constructing the circuit, so you can connect proper bias pins and output pins. (IR = Infra Red light). The basic purpose of TSOP1738 is to convert the IR signal to electric signals.

Hardware Required

S.noComponentValueQty
1.IR Receiver TSOP17381
2.Resistor220Ω3
3.LED3
4.ArduinoUno1
5.Connecting Wires

Circuit Diagram

Working Explanation

As TSOP1738 and Arduino are pain parts of this project, TSOP1738 is an IR receiver with an amplifier that acts as a switch and converter within a circuit. It has a single input and output that only reacts to the input IR signal. The TSOP1738’s main function is to convert IR impulses to electric signals. Every IR receiver operates on a specific frequency. TSOP1738 operates on a 38 kHz IR frequency. It may act owing to a current leakage or other problems if the frequency is higher or lower, but it will not fully perform. It employs silicon-based technology, which operates on a micro-scale and is extremely sensitive and efficient in its activities.

Arduino Code

To read the IR rays from the remote control by Arduino board we need an external library which is the IRremote library, you can get the IRremote library here.  (How to insert new library in Arduino IDE)

In this project first, we have executed the IRrecvDemo example program from the Arduino IR library example and decoded IR rays from remote.

Then we used decoded data as switching conditions in the Arduino sketch to turn on and off the three LEDs.

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Screenshot

IR-receive-serial-new1 (1)

Then we used decoded data as switching conditions in the Arduino sketch to turn on and off the three LEDs.

Arduino Code For IR Remote Control

#include <IRremote.h>
 
int RECV_PIN = 11; // 
int output1 = 2;
int output2 = 4;
int output3 = 6;
int itsONled[] = {0,0,0,0};

#define code1  0xFF807F // 
#define code2  0xFFA05F // 
#define code3  0xFF906F // 
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
void setup()
{
  Serial.begin(9600);   // 
  irrecv.enableIRIn();  // 
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(output3, OUTPUT);
}
 
void loop() {
  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) {
       case code1:
         if(itsONled[1] == 1) {        // 
            digitalWrite(output1, LOW);   // 
            itsONled[1] = 0;           // 
         } else {                      // 
             digitalWrite(output1, HIGH); // 
             itsONled[1] = 1;          // 
         }
          break; 
       case code2:
         if(itsONled[2] == 1) {
            digitalWrite(output2, LOW);
            itsONled[2] = 0;
         } else {
             digitalWrite(output2, HIGH);
             itsONled[2] = 1;
         }
          break;
       case code3:
         if(itsONled[3] == 1) {
            digitalWrite(output3, LOW);
            itsONled[3] = 0;
         } else {
             digitalWrite(output3, HIGH);
             itsONled[3] = 1;
         }
          break;          
    }
    Serial.println(value); // you can comment this line
    irrecv.resume(); // Receive the next value
  }
}

Screenshot

IR-receive-serial-remote-new

In this Arduino sketch, we used

  • code1 as  0xFF807F
  • code2 as  0xFFA05F
  • code3 as  0xFF906F

you can change these codes according to your remote key code received at Arduino serial Monitor from the first Arduino sketch. (Arduino Code for Receiving IR as Hex code).

Applications

You can find IR Remote controls and corresponding IR Receivers in almost all major electronic appliances like televisions, air conditioners, TV boxes, audio players, and many more.