Controlling LED’s Using IR Remote and Arduino



Controlling LED’s Using IR Remote:  I have already posted an article how to use IR transmitter and IR receiver with Arduino. I recommend you to read getting started tutorial on Arduino if you are new to Arduino programing In this tutorial, we will learn about IR communication and also how to interface the IR remote with Arduino using IR Receiver. How to control LED’s with IR remote. IR receiver is interfaced with Arduino to receive IR commands from IR remote. Arduino will receive these commands and take action accordingly. If you are new to Arduino, Check this complete list of Arduino tutorials.



IR Communication

IR or infra-red is a common communication, and easily to use wireless communication. The light of IR is visible like similar light, have a low frequency but slightly longer wavelength. The IR LED detects and works at 980 nm (nanometer), that’s considered near to infra-red.

IR Signal



The IR signal is looking infra-red that’s flashing turn ON and OFF 38,500 time per second that means IR light is undetectable to the human eye.

Important Concepts

The IR detector sends low pulses that can be measured to determine what information the IR remote is sending, it’s an example of using PWM for communication.

  • Carrier signal

The IR remote use a 38,500 remote signal to transmit the pulse durations.

IR interfacing with Arduino

IR Receiver

IR Receiver has three terminals

  1. +5V VCC
  2. GND
  3. OUT (Digital Output)

This is a multipurpose infrared sensor, like color detection (between basic contrasting colors), fire detection, line sensing, etc and also as an encoder sensor. The sensor provides a digital output. An on board LED is used to indicate the presence of an object. This digital output can be directly connected to an Arduino to read the sensor OUTPUT.

Features

  • Input Voltage: 5V DC
  • Comes with an easy to use digital output
  • Can be used for wireless communication and sensing IR remote signals

Hardware Required for Controlling LED’s Using IR Remote

  • Arduino Uno Board
  • IR Receiver TSO1838
  • IR Remote
  • Resistance
  • 3 LED’s

Circuit Diagram of Controlling LED’s Using IR RemoteControlling LED's using IR remote and Arduino

Arduino interfacing with IR sensor is very simple like interfacing of Switch with the Arduino.The Red, Green and Blue Led is connected with digital pins of Arduino 13,9 and 10 respectively. And IR receiver pin 1 Signal pin connected with pin  11 pin 2 is ground and pin 3 to +5V. Check this tutorial on LED blinking using Arduino for more information.

Coding of Controlling LED’s Using IR Remote

#include<IRremote.h>    // Header file for IR remote

int receiver = 11;  Signal Pin of IR receiver to Arduino Digital Pin 11

int Redled= 13;   // initialize the Red Led on Digital Pin 13 of Arduino

int Greenled=9;   // initialize Green Led on Digital Pin 9 of Arduino

int Blueled=10;   // initialize Blue Led on Digital Pin 10 of Arduino

IRrecv irrecv(receiver);      // create exemplar of 'irrecv'

decode_results results;       // create exemplar of 'decode_results'

void setup()                 // Setup code which runs once time

{

  pinMode(Redled,OUTPUT);    // Define the pin of arduino for OUTPUT

  pinMode(Greenled,OUTPUT); // Define the pin of arduino for OUTPUT

  pinMode(Blueled,OUTPUT);   // Define the pin of arduino for OUTPUT

  Serial.begin(9600);                            // To Start Serial communication

  Serial.println("IR Receiver Button Decode");

  irrecv.enableIRIn();         // Start the receiver

}

void loop()                              //( LOOP: RUNS CONSTANTLY )

{

  if (irrecv.decode(&results)) // have we received an IR signal?

  {

    translateIR();

    irrecv.resume(); // receive the next value

  } 

}

void translateIR() // takes action based on IR code received

// describing Remote IR codes

{

  switch(results.value)

  {

// Define the IR Remote

  case 0xFFA25D: Serial.println(" POWER");break;

  case 0xFF629D: Serial.println(" STOP");break;

  case 0xFFE21D: Serial.println(" MUTE");break;

  case 0xFF22DD: Serial.println(" MODE");break;

  case 0xFF02FD: Serial.println(" REVERSE");break;

  case 0xFFC23D: Serial.println(" EQ");break;

  case 0xFFE01F: Serial.println(" PREVIOUS");break;

  case 0xFFA857: Serial.println(" NEXT");break;

  case 0xFF906F: Serial.println(" FORWARD");break;

  case 0xFF6897: Serial.println(" INCREASE");break;  

  case 0xFF9867: Serial.println(" DECREASE");break;

  case 0xFFB04F: Serial.println(" 0");   

  digitalWrite(Redled,LOW);

  digitalWrite(Greenled,LOW);

  digitalWrite(Blueled,LOW);

  break;

  case 0xFF30CF: Serial.println(" 1");   

  digitalWrite(Redled,HIGH);break;

  case 0xFF18E7: Serial.println(" 2");   

  digitalWrite(Greenled,HIGH);break;

  case 0xFF7A85: Serial.println(" 3");   

  digitalWrite(Blueled,HIGH);break;

  case 0xFF10EF: Serial.println(" 4");    break;

  case 0xFF38C7: Serial.println(" 5");    break;

  case 0xFF5AA5: Serial.println(" 6");    break;

  case 0xFF42BD: Serial.println(" 7");    break;

  case 0xFF4AB5: Serial.println(" 8");    break;

  case 0xFF52AD: Serial.println(" 9");    break;

  case 0xFFFFFFFF: Serial.println(" REPEAT");break; 

  default:

    Serial.println(" other button   ");

  }// End Case

  delay(500); // Do not get immediate repeat}

Video results



Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,395 other subscribers