Arduino – Control LEDs with a Remote Control

Control LED (1)

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.

Control LED (1)

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

Remote Control LEDs (1)

Upload this code

/*
* IRremote Library – Copyright 2009 Ken Shirriff
* created by Rui Santos, http://randomnerdtutorials.wordpress.com
* 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
}

Read more: Arduino – Control LEDs with a Remote Control

Leave a Comment

Your email address will not be published. Required fields are marked *