TV Remote Controlled RGB Led

by sangit-niroula in Circuits > Remote Control

3767 Views, 58 Favorites, 0 Comments

TV Remote Controlled RGB Led

IR remote project with arduino(tv remote)

INTRODUCTION


Infrared remote control project is one of the popular projects for arduino lovers. We are here talking about the tv remote. There are various button of tv remote that are not used. Also if we can make this tv remote to control things other than tv than this will be cool and great.Arduino is an open source development board which is very good research and learning platform for technical and non technical person. It is very easy and comfortable to use in most of the situation from school project to the professional job. So it gives us knowledge about electronics and help develop idea of all age students.

Learning arduino is awesome with enough hardware.Infrared remote works on 38khz. Here I used a chinese cheap remote.

Components Required

arduino.png
bread board.jpg
jumpers.jpg

1. computer or laptop

2. arduino (uno)

3. tv remote

4. IR receiver

5. some jumpers

6. Breadboard

Hardware Setup or Circuit Diagram Preparation

light_arduinopna4602.gif

connect your components as shown in the diagram below with the help of bread board carefully.IR receiver is a three pin device and it has internal op-amp and decoder. It receives the binary signal of IR transmitted from the remote of tv and sends it to the pin 11 of the arduino.

=> face ir receiver towards you

=> connect right most pin to 5V of arduino

=> connect middle pin to gnd of arduino

=> connect left most pin to pin D11 of arduino digital i/o lines

Installing IRremote.h Library to Your Arduino IDE

=> download the arduino IRremote library by clicking here.

=> extract it and copy the folder of IRremote to the following directory.

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

=> Remove the library folder named as RobotIRremote from the above directory

=> Then restart your arduino IDE if you already opened it.

IRremote library installation complete.

Code of the Project

Test code

=> go to file>example>IRremotemaster> irrecvdemo

or

=> copy and paste the following code to your arduino ide

#include<IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {

Serial.begin(9600);

irrecv.enableIRIn();

}

void loop() {

if (irrecv.decode(&results))

{ Serial.println(results.value, HEX);

irrecv.resume();

}

}

=> after uploading this code then open serial monitor and press any key and note the hex code with corresponding key that is shown in Serial monitor.

RGB Led Connection

rgb led.jpg

=> connect your rgb led as described

red to pin 13

green to pin 10

blue to pin 9 of arduino

=> copy and paste the following code to your arduino IDE and upload it to your arduino. press your remote key from 1 to 7. various types of color can be achieved.

note: replace hex_code by your corresponding hex code that you noted before

here replace 1, 2 ,3,4,5,6,7 by your 0xhex_code obtained by pressing 1,2,3,4,5,6,7 .

(zero small x (0x) is necessary in front of your hex code. )

#include<IRremote.h>
int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {

Serial.begin(9600);

irrecv.enableIRIn();

}

void loop() {

if (irrecv.decode(&results))

{

Serial.println(results.value, HEX);

if(results.value==1)

{

digitalWrite(red,HIGH);

digitalWrite(green,LOW);

digitalWrite(blue,LOW);

}

else if(results.value==2)

{

digitalWrite(red,LOW);

digitalWrite(green,HIGH);

digitalWrite(blue,LOW);

}

else if(results.value==3)

{

digitalWrite(red,LOW);

digitalWrite(green,LOW);

digitalWrite(blue,HIGH);

}

else if(results.value==4)

{

digitalWrite(red,HIGH);

digitalWrite(green,HIGH);

digitalWrite(blue,LOW);

}

else if(results.value==5)

{

digitalWrite(red,HIGH);

digitalWrite(green,LOW);

digitalWrite(blue,HIGH);

}

else if(results.value==6)

{

digitalWrite(red,LOW);

digitalWrite(green,HIGH);

digitalWrite(blue,HIGH);

}

else if(results.value==7)

{

digitalWrite(red,HIGH);

digitalWrite(green,HIGH);

digitalWrite(blue,HIGH);

}

else {

digitalWrite(red,LOW);

digitalWrite(green,LOW);

digitalWrite(blue,LOW);

}

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

}

}

Possible Problems

IR remote project with arduino(tv remote)

Every type of remote do not give simple number after decoding like 1, 2, 3 etc instead they give long hex code. This can not be directly used in if-else statement. So there is a method of placing 0x in front of the hex code in if else statement.so try the following code after you run the test code given above and either copy paste or modify the test code.

#include<IRremote.h>

int before;

int RECV_PIN = 11;

int led=13;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup(){

Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver

before=0;

pinMode(led, OUTPUT);// sets the digital pin as output

}

void loop() {

if (irrecv.decode(&results))

{

Serial.println(results.value, HEX);

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

}

if(results.value==0xyour hex code) // for example 0xFF52AD

{

if(before==0)

{

digitalWrite(led,HIGH);

before=1;

}

}

else

{

digitalWrite(led,LOW);

before=0;

}

}



first open serial monitor to veiw the decoded hex code and use hex code in if else condition as guided above.
note that in this section where 'your hex code' is written there copy the code of your code shown in serial monitor of your arduino IDE.

comment for your queries and share the post so that other can view it. if i have done mistake please kindly make me known about that.. thanks for viewing the post...............