Arduino - Control LEDs With a Remote Control





Introduction: Arduino - Control LEDs With a Remote Control

About: Author, Blogger, Electronics Enthusiast and Entrepreneur. For complete Electronics Projects and Tutorials go to:

Hi guys,
I'm sharing with you a project I've recently done. I'ts about how you can control some LED's with a remote control and your Arduino. But you can apply this to any electronic device such as motors , lights for example.

you can visit my website for more electronic projects, interesting news and tips:

Step 1: IR Library

First you need to go to this page and download the IR library. You just need to follow the read me file to install. I think that any IR remote control can do this, I’ll be using a Philips Universal one.

Step 2: Parts Required

Parts list:
1x Arduino
1x Breadboard
1x Remote control
1x IR receiver ( I’ll be using TSOP4838)
4x LED’s
4x 220ohm resistors
Jumper cables

The infrared receiver has 3 pins:
First pin: Vout, outputs HIGH when no signal is present and LOW when a mark is received.
Second pin: GND.
Third pin: Vcc.

Step 3: Circuit Diagram

You need to wire your circuit something like this.
And then I went to the arduino IDE > file>examples>IRremote> IRrecvDemo. You need to upload the sketch to your arduino, open the serial monitor and start using your remote control and see which values the arduino is receiving.

After a while I’ve wrote down which values appear in the serial monitor when you press the volume up key or any other key, and write it down for all the keys you want to use. And they were:

Power:  E240
Forward: E250
Reverse: E248
Volume+: E244
Volume-: E254
Mute: E24C7
You will need to convert these hexadecimal numbers to decimal, you can use this tool for that.

Step 4: Upload the Arduino Code

Upload this code

* IRremote Library - Copyright 2009 Ken Shirriff
* created by Rui Santos,
* Control LED's with a remote control
* 2013

#include <IRremote.h>

int IR_Recv = 3;   //IR Receiver Pin 3
int g_ledPin = 5;  //green LED pin 5
int y_ledPin = 6;  //yellow LED pin 6
int r_ledPin = 9;  //red LED pin 9
int b_ledPin = 10; //blue LED pin 10
int ledPins[] = {5, 6, 9, 10};  //array with all the LED's pins
int ledStates[] ={0, 0, 0, 0};  //this means the LED's states at first is 0 = LOW
int i=0;  //LED index for the arrays

IRrecv irrecv(IR_Recv);
decode_results results;

//variables to make the LED blink when selected
int ledState = LOW;             // ledState to turn the LED on or off
long previousMillis = 0;        // stores last time LED was updated
long interval = 1000;           // interval at which to blink (milliseconds)

void setup(){
  Serial.begin(9600);  //starts serial communication
  irrecv.enableIRIn(); // Starts the receiver
  pinMode(g_ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(y_ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(r_ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(b_ledPin, OUTPUT);      // sets the digital pin as output

void loop(){
  //decodes the infrared input
  if (irrecv.decode(&results)){
    long int decCode = results.value;
   //switch case to use the selected remote control button
   switch (results.value){
      case 57936: //when you press the Forward button
       //this if/else statement makes sure that LED is ON or OFF before move to the next LED
          digitalWrite(ledPins[i], LOW);
          digitalWrite(ledPins[i], HIGH);
       Serial.println("Next LED");
       //makes sure that when we reach the last LED it goes to the first LED again
      case 57928: //when you press the Reverse button
        //this if/else statement makes sure that LED is ON or OFF before move to the previous LED
          digitalWrite(ledPins[i], LOW);
          digitalWrite(ledPins[i], HIGH);
        Serial.println("Previous LED");
        //makes sure that when we reach the first LED it goes to the last LED
      case 57932: //when you press the Mute button
        if(ledStates[i]==0){ //if the LED is off, It will turn on
          Serial.println("Turns ON the LED Selected");
          digitalWrite(ledPins[i], HIGH);  //sets the LED on
          ledStates[i]=1;                  //updates the LED state
          Serial.println("Turns OFF the LED Selected"); //else: the LED is on, It will turn off
          digitalWrite(ledPins[i], LOW);   //sets the LED off
          ledStates[i]=0;                  //updates the LED state
      case 57920: //when you press the Power button
        Serial.println("Turns OFF all the LED's");
        digitalWrite(g_ledPin, LOW);   // sets the green LED off
        ledStates[0] =0;               // updates the LED state
        digitalWrite(y_ledPin, LOW);   // sets the yellow LED off
        ledStates[1] =0;               // updates the LED state
        digitalWrite(r_ledPin, LOW);   // sets the red LED off
        ledStates[2] =0;               // updates the LED state
        digitalWrite(b_ledPin, LOW);   // sets the blue LED off
        ledStates[3] =0;               // updates the LED state
    irrecv.resume(); // Receives the next value from the button you press
  //this if statment makes the LED blink if it's selected and off
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;  
      // if the LED is off turn it on and vice-versa:
      if (ledState == LOW)
        ledState = HIGH;
        ledState = LOW;
      // set the LED with the ledState of the variable:
      digitalWrite(ledPins[i], ledState)

Step 5: And It's Done

Thanks for reading, let me know what you think about my projects, leave a comment and don't forget to visit my website for more tutorials.

<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>



  • Casting Contest

    Casting Contest
  • Make it Move Contest

    Make it Move Contest
  • Clocks Contest

    Clocks Contest

We have a be nice policy.
Please be positive and constructive.




So the error i get is that only one LED lights up out of the 4. I've tried changing the other leds out and the pins they're connected to but no difference. the arduino does receive the IR signal but it doesn't seem to be doing anything to the led that lights up. in the serial moniter, the IR signals look something like :

"21448776745 waiting"

1 reply

then remove the other 3 LOL

LEDREMOTE.ino: In function 'void loop()':

LEDREMOTE.ino:112:5: error: expected ';' before '}' token

Multiple libraries were found for "IRremote.h"

Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

Not used: C:\Users\SERVER\Documents\Arduino\libraries\Arduino-IRremote-master

1 reply

I also got the same error.

Add ';' at the end of line 111 - 'digitalWrite(ledPins[i], ledState);'.

It's too late for you but hope it helps someone else with same error.

Hi der, I've found a exciting website for dis.

am using TV remote to control my motor but i am getting an error can anyone fix it.

Also, after long pressing the button getting , i am getting a no. repeated for long press ,which is different than the first one.

#include <IRremote.h>

//ONKYO Remote

int RECV_PIN = 11; //Pin 11 is for the IR remote

IRrecv irrecv(RECV_PIN);

decode_results results; // The name of the decode_results function

int led = 13; // Pin 13 is for the builtin

LED on the arduino

const int Motor1Pin1 = 7; // Pins for the motors so 7, 6, 5, 4

const int Motor1Pin2 = 6;

const int Motor2Pin1 = 5;

const int Motor2Pin2 = 4;

void setup() {


pinMode(led, OUTPUT); // OUTPUT the LED

pinMode(Motor1Pin1, OUTPUT); // OUTPUT the motor pins

pinMode(Motor1Pin2, OUTPUT);

pinMode(Motor2Pin1, OUTPUT);

pinMode(Motor2Pin2, OUTPUT);


void loop() {

digitalWrite(led, HIGH); // When the arduino is ready to get commands the LED will turn on

if(irrecv.decode(&results)) { // if the arduino receives a signal from the remote...


if(results.value == 0x4BB641BE) { // Here's where you need to change the value from

4BB641BE to the one in your serial monitor but always put 0x before the value (the number zero

and the letter x)

moveForward(); // move forward


else if(results.value == 0x4BB6C13E) { // Change the value for the Backward



else if(results.value == 0x4BB621DE) { // Change the value for the Left



else if(results.value == 0x4BB6A15E) { // Change the value for the Right



else if(results.value == 0x4BB6E916) { // Change the value for the Stop





// voids for all the mouvement. If it doesnt work for you please feel free to change it

void moveForward() {

digitalWrite(Motor1Pin2, HIGH);

digitalWrite(Motor1Pin1, LOW);

digitalWrite(Motor2Pin2, LOW);

digitalWrite(Motor2Pin1, HIGH);


void moveBackward() {

digitalWrite(Motor1Pin1, HIGH);

digitalWrite(Motor1Pin2, LOW);

digitalWrite(Motor2Pin1, LOW);

digitalWrite(Motor2Pin2, HIGH);


void moveLeft() {

digitalWrite(Motor1Pin1, LOW);

digitalWrite(Motor1Pin2, HIGH);

digitalWrite(Motor2Pin2, HIGH);

digitalWrite(Motor2Pin1, LOW);


void moveRight() {

digitalWrite(Motor1Pin2, LOW);

digitalWrite(Motor1Pin1, HIGH);

digitalWrite(Motor2Pin1, HIGH);

digitalWrite(Motor2Pin2, LOW);


void Stop(){

digitalWrite(Motor1Pin2, LOW);

digitalWrite(Motor1Pin1, LOW);

digitalWrite(Motor2Pin1, LOW);

digitalWrite(Motor2Pin2, LOW);


If anyone is having trouble with getting this to compile go to your IRlibrary folder and delete the robot files then it will work thats what i did and works great

I'm confused cos I'm a newb. Is the numbers after 'case' you know the 'case 59732'. are those the decodings of the remote ir signal?

Arduino: 1.6.6 Hourly Build 2015/07/21 05:42 (Windows 7), Board: "Arduino Uno"

IRrecvDemo.ino: In function 'void setup()':

IRrecvDemo:17: error: redefinition of 'void setup()'

sketch_jul26d:1: error: 'void setup()' previously defined here

IRrecvDemo.ino: In function 'void loop()':

IRrecvDemo:23: error: redefinition of 'void loop()'

sketch_jul26d:6: error: 'void loop()' previously defined here

Multiple libraries were found for "IRremote.h"

Used: D:\maitreya\Arduino\arduino-nightly\libraries\RobotIRremote

Not used: C:\Users\Maitru_2\Documents\Arduino\libraries\Arduino-IRremote-master

redefinition of 'void setup()'

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

waht to do with this

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"

In file included from sketch_jul26b.ino:23:

C:\Program Files (x86)\Arduino\libraries\RobotIRremote/IRremoteInt.h:187: error: 'RAWBUF' was not declared in this scope

what is the meaning of this

there comes this error

hey, I tried your project and it worked, but I have a little issues related to the distance at which I use my remote. The LEDs can only be switched at really short distances for me. Is it the same with you or my receiver isn't powerful enough ?

in this we have to just change the received value from ir after the word " case 1535313823"...or to do sometng else..? plz help .

undefined reference to `IRrecv::IRrecv(int)'

collect2: error: ld returned 1 exit status

Error compiling.

please help:( i hv no idea what that means

Hi,when I want use serial monitor to see which values the arduino is receiving.

But I cannot see any value returned. Is that because I don't use the philips remote?

hi when i copy your code i get:

ir-led.ino: In function 'void loop()':

ir-led.ino:105:5: error: expected ';' before '}' token

Error compiling.

2 replies

That mean you have a syntax error on line 105...

In the IDE, click on settings and activate "line number" option... Go to the line 105 and fix ot

Solved :) i missed this thingie ";" on line 105

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope

what is it asking for and how can I fix it