Introduction: Arduino - Control LEDs With a Remote Control

Picture of Arduino - Control LEDs With a Remote Control

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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>


markm285 (author)2016-12-12

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"

TimC211 (author)markm2852017-01-25

then remove the other 3 LOL

Christo6911 (author)2015-04-06

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

agmhere (author)Christo69112016-04-06

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.

DesmondM (author)2016-02-09

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

Alok Shaw (author)2016-01-06

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);


electric1981 (author)2015-11-13

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

garrett.allen.7 (author)2015-01-15

tried using the library file and got this error C:\Program Files (x86)\Arduino\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope

tried copying and pasting from above and IRrecvDemo.ino: In function 'void loop()':

IRrecvDemo:112: error: expected `;' before '}' token

can you please advise

sumitk31 made it! (author)garrett.allen.72015-10-31

download IRremote library from link below

after download, extract it and rename it and just delete " Arduino-" from it

copy it to arduino library folder

mine is :---- c > program files (x86) / arduino / libraries

and paste it here

now restart your arduino software

go to: Files / Examples / IRremote / IRrecord

and compile it or verify it if there is no error then its done

i got the same problem please advice me what to do

JunadA (author)2015-10-04

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?

maitrteya (author)2015-07-26

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

maitrteya (author)2015-07-25

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

ahmedH22 (author)2015-06-25

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 ?

ahmedH22 (author)2015-06-25

kavish laxkar (author)2015-06-23

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

Sarvasv Kulpati (author)2015-06-12

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

Sarvasv Kulpati (author)2015-06-12

collect2: error: ld returned 1 exit status

Error compiling.

please help:( i hv no idea what that means

xiang.liu.5030 (author)2015-04-16

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?

Ramunekaz (author)2015-02-25

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.

Christo6911 (author)Ramunekaz2015-04-07

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

Ramunekaz (author)Ramunekaz2015-02-25

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

nazir97 (author)2015-03-09

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

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

Aryan25107 (author)2015-01-28

very nice project but i have some ir photodiode receiver can u give me sketch for it.

nicholas.mcclure2 (author)2015-01-19

hello. I am trying to code this for only one LED for 1 button on the remote control to my television. Every time I try to modify your code, I always get a whole bunch of errors, but the most annoying one is "Case label '********1' not within a switch statement. it always adds the 1 on the end, and I would like help on fixing this along with the other numerous errors that occumpany it. If you would please kindly ether message me or send code for only one led, that would be fantastic! great job by the way! Please respond!


dj505Gaming (author)2014-12-29

I noticed that in the code you can change HEX to DEC to avoid the conversion.

dj505Gaming (author)dj505Gaming2014-12-29

Specifically the example code for IRrecvDemo

KUPITO (author)2014-12-12

Amazing! Thanks for sharing this bro, this was my first project with an arduino. I was having a hard time at the beginning but it was because the pins of my receiver were different according to the datasheet. As an electric engineer. this could come pretty handy you could even control high power applications, instead of having a LED a relay would take place or a timer. Applications are limitless

prashanna.nepal.9 (author)2014-11-17

Thanks dude this works perfectly for me.

I used this to operate a fan.

micmac (author)2014-10-22

The only tiny error I found (beside a missing ';') is that the IR discovery sketch used to capture the IR codes from the controller calls for a different receiver pin, 11 if I remember, where your setup calls for pin 3. Once that change is made in the code, it captures the IR perfectly and then goes on to control the LEDs perfectly. I'm well on my way to my remote control swiveling ceiling mounted garage fan. Thanks.

servalente (author)2014-08-12

Caro Rui, gostaria, se possível, que me desse uma ajuda numa questão relativa ao IR a funcionar com o arduino e controlo de leds. Faço modelos à escala, e no projecto que tenho em mãos gostava de aplicar luzes num camião à escala 1/8. Tenho tudo ligado, e quase a funcionar na perfeição, mas ainda não consegui deixar os sinais de pisca a funcionar. Tenho três códigos do IR disponiveis, para os piscas de esq. da direita e para os de emergência. Não consigo arranjar maneira de os deixar a piscar enquanto tenho outras luzes ligadas. Acha que me pode ajudar?

Obrigado desde já pela paciência.

ehameedullah (author)2014-02-15

i love instructable site becauze they do alot of different crazy project

ehameedullah (author)2014-02-15

i love instructable site becauze they do alot of different crazy project

Kamokaki (author)2014-01-25

hi im trying to controll my arduino to move a servo.

(Could you help me put in the code?

The controll gives off the infrared as i press left: FF22DD and right FFC23D. Please help me figure this out.)

#include <Servo.h>
#include <IRremote.h>

unsigned long Value1 = 0xFF22DD; // where XXXXXXXX is on our your remote's values
unsigned long Value2 = 0xFFC23D; // where XXXXXXXX is another button on your remote

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

Servo servo1;

// the setup routine runs once when you press reset:
void setup() {

irrecv.enableIRIn(); // Start the receiver

// initialize the digital pin as an output.

servo1.attach(10); // attack servo to digital pin 10

// the loop routine runs over and over again forever:
void loop() {

if (irrecv.decode(&results)) {

Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value

if(results.value == Value1) {
else if (results.value == Value2){

rogertikboy (author)2014-01-15

here is the error I got

IRrecvDemo:16: error: 'IRrecv' does not name a type
IRrecvDemo:17: error: 'decode_results' does not name a type
IRrecvDemo.ino: In function 'void setup()':
IRrecvDemo:27: error: 'irrecv' was not declared in this scope
IRrecvDemo.ino: In function 'void loop()':
IRrecvDemo:32: error: 'irrecv' was not declared in this scope
IRrecvDemo:32: error: 'results' was not declared in this scope
IRrecvDemo:67: error: expected `;' before '}' token

thanks again,

RuiSantos (author)rogertikboy2014-01-16

You need to install the IR library...

You didn't follow throught the Step number 1.. Please read that step carefully.

Have a nice day,


Vaibhav1o1 (author)2013-05-31

Dude the code is wrong!!

RuiSantos (author)Vaibhav1o12013-06-06

sorry for the long delay to answer... what you mean? it works fine for me and for a lot of people who already tried...
tell me what's not working, thanks!

tashvin (author)RuiSantos2013-12-20

hey dude what if i use a remote control which i got with the arduino starter kit?
thanks :)

lpereira15 (author)2013-12-17

what if I want to do this without using a library?

RuiSantos (author)lpereira152013-12-17

If you don't want to use the library, you'll need to write a lot of code to do this simple project.
What I recommend you to do is to download the library and my code.
See which functions I'm using from the library.
And understand what they do.

Then instead of using the functions from the library you can create your own functions on a single Arduino skecth...

I hope this helps,

adrianalexander (author)2013-11-06

I've installed the IRremote library. Opened iRrevc, compiled and uploaded to Arduino. All looks as it should yet nothing prints in the serial monitor. I've tried ALL the baud rates (although I imagine you used 9600) yet the issue persists. My circuit is identical to yours. Only difference in brand/model of the IR Receiver... I've tried 2. One I salvaged from an old sony blu ray player and the other I bought at RadioShack (276-0640). Both are:
38kHz IR receiver
Supply Current: 0.27-0.45mA
Supply Voltage: 2.5-5.5V
Output Volt low: 100mV

I've also tried several remotes that I've confirmed are in perfect working order.

Any thoughts on the matter? If you'd like, PM me.

Thank you!!

faziefazie (author)2013-09-04

I follow your circuit diagram, but there are several problems
1. when I upload the code to Arduino, I keep get the wrong message that my Arduino port can't be read by my PC, but if I don't connect the ground and vcc from the circuit to Arduino, the port can be read by my PC.
2. After I upload the code (without connect the circuit and Arduino), I can't test my remote because the serial monitor can't be open if the circuit is connect to Arduino.
3. My IR receiver get hot when I connect it with Arduino.

is that something I did wrong? or can you give me more explanations about how to read the remote.


RuiSantos (author)faziefazie2013-09-04

thanks for trying my project!
1) I didn't understand exactly that problem... :S can you upload others arduino sketches to your arduino? did you upload the IR library to the libraries folder from the arduino IDE?
2) If the answer I gave you in 1) doens't apply to you... try to reinstall the arduino IDE again and try to upload my code.
3) which IR receiver you're using?
did you follow exactly my schematics? because that shouldn't be happening!
Please let me know what I can help you more with

About This Instructable




Bio: Author, Blogger, Electronics Enthusiast and Entrepreneur. For complete Electronics Projects and Tutorials go to:
More by RuiSantos:ESP8266 Web Server (Without Arduino)Arduino Simple Memory GameArduino – Datalogger with Temperature Sensor and Photoresistor
Add instructable to: