Lâmpada RGB controlada remotamente IR usando Arduino

IR Remote Controlled RGB Lamp Using Arduino

Arduino can be used to vary different colors on the RGB (LED) lamp. We know that Arduino can vary the intensity of the LED using its analog outputs, generating PWM. The RGB lamp has 3 internal LEDs – red, green and blue. Arduino varies the intensity of all three red, green and blue LEDs and thus gives different mixtures of these three colors and generates different colors like CYAN, PINK, YELLOW, MAGENTA, WHITE etc. At most, we can have many numbers of color combinations – it means different colors. Therefore, Arduino can generate many different colors using RGB lamp.

What if we could turn the RGB lamp ON or OFF or vary its different colors using the IR remote control? Especially the normal and readily available portable IR remote control that we can find in almost every home for TV, AC, music systems, DVD or even for STB (set top box). It means we can turn ON or OFF the lamp or set any color of lamp using this IR remote control – any IR remote control. Sounds interesting?

The presented project demonstrates how to turn on/off or vary the colors of the RGB lamp using any IR remote control (like TV, DVD, AC, STB etc) with the help of Arduino. The project uses a regular decoder IR remote control (STB), TSOP IR sensor and Arduino UNO board. Anyone can use any type of IR remote control. He just needs to change the remote control codes in the Arduino sketch (program) for the remote control. This procedure is also described here when explaining the operation. So let's see how this is done. First, see the circuit diagram followed by its description and operation.

CIRCUIT DESCRIPTION

As shown in the figure, the circuit is built using 3 components, just an Arduino board, IR sensor and RGB LED.

• The TSOP1738 sensor has 3 terminals (1) Vcc (2) Gnd and (3) output. Its Vcc terminal receives 5 V from the board and the Gnd terminal is connected to the board's ground. The sensor output is connected to digital input pin 12 on the Arduino board.

• The RGB LED is of the common anode type. Its common anode receives 5V power from the board through the current limiting resistor and the red, green and blue LED terminals are connected to analog output pins 9, 10 and 11 respectively.

Here is the snap of the circuit arrangement.

Protótipo de controlador de lâmpada RGB baseado em Arduino e IR Remte

Figure 1: RGB lamp controller prototype based on Arduino and IR Remte

CIRCUIT OPERATION

First, we have to decide which are the different buttons on the IR remote control that we will use to vary the colors of the RGB ball. We want to perform the following actions -:

1. RGB lamp ON/OFF

2. Increase/decrease the intensity of the red color

3. Increase/decrease the intensity of the green color

4. Increase/decrease the intensity of the blue color

So we need 7 buttons. I used the set-top box remote control (STB) which has many buttons such as 0 to 9 digit buttons, volume control buttons, channel up/down buttons, arrow buttons, etc. From all these buttons, I have selected the following 7 buttons for different operations -:

Tabela listando botões do controle remoto IR e respectivas funções no controle de lâmpada RGB

Fig. 2: Table listing the IR remote control buttons and their respective functions in RGB lamp control

After deciding on the buttons, the next step is to decode the codes for those buttons. As we know when any button is pressed remotely it will send a code and based on that code the action will be performed. So, to decode these codes I used the IRremote functions and the IRremote library for Arduino, available on the internet.

Then download the library and use an example to decode the remote control button codes. Load the program into the Arduino microcontroller and connect the IR sensor as shown in the figure. Now point the remote at the IR sensor and press the button. Open the serial monitor and you can see the code of the pressed button in the form of numbers. Write down the codes of the necessary buttons, as I wrote down the codes according to the following table -:

Tabela listando botões do controle remoto IR e respectivos códigos IR

Fig. 3: Table listing IR remote control buttons and respective IR codes

In the Arduino sketch above, codes corresponding to the button pressed to perform an action are used as per the previous table. Now let's see the actual operation.

• When the power button is pressed by the remote control, the RGB lamp will turn on. Pressing the same button once again will turn off the RGB lamp. So, the power button on the remote control is used to turn on/off the RGB lamp. The message is also displayed on the serial monitor as “RGB bulb ON” and “RGB bulb OFF”

• The volume up button is used to increase the intensity of the red color (RED LED) and the volume down button decreases the intensity of the RED LED. The RED LED intensity is increased from 1% to 100%. As the buttons are pressed, the pulse width at pin 11 of the analog output increases or decreases from 1 to 100% to change the intensity of the red LED. The message is displayed on a serial monitor as “red intensity has increased XX%” or “red intensity has decreased XX%”.

• In the same way, to change the intensity of the blue color, two other buttons CH+ and CH- are used. The CH+ button will increase the intensity of the blue color and CH- will decrease it. These two buttons will increase or decrease the pulse width on pin 9 of the analog output and thus vary the intensity of the blue LED from 1 to 100%.

• Finally, to vary the intensity of the green LED, the up and down arrow buttons are used. The up arrow button will increase the intensity and the down arrow key will decrease the intensity. These two buttons will increase or decrease the pulse width on pin 10 of the analog output and vary the intensity of the green LED from 1 to 100%.

• So by changing/varying/setting different color intensities using all these six buttons we can get different colors from the RGB lamp.

Project source code

###

 #include


 int IRpin = 12; // pin for the IR sensor


 int red = 9;

 int green = 10;

 int blue = 11;

 
/////////////////// initial values ​​of color intensity/////////////////////

 int red_intensity=130,i; 

int blue_intensity=130;

 int green_intensity=130;

 IRrecv irrecv(IRpin);

 decode_results results;


 void setup

 {

 Serial.begin(9600); // initialize serial communication

 Serial.println("Remote control RGB Light");

 irrecv.enableIRIn; // Start the receiver

 }


 void loop

 {

 // loop until no button is pressed no code is received

 while(!(irrecv.decode(&results))); 

if (irrecv.decode(&results)) // when code is received

 { // start comparing results

 if(results.value==6296) // for power on button

 {

 analogWrite(red,red_intensity); // turn ON bulb with
 
analogWrite(green,green_intensity); // default color

 analogWrite(blue,blue_intensity);

 Serial.println("RGB Bulb ON"); // display message

 }

 else if(results.value==2200) // for even times

 {

 analogWrite(red,255); // turn OFF bulb

 analogWrite(green,255);

 analogWrite(blue,255);

 Serial.println("RGB Bulb OFF");

 }

 else if(results.value==6338) // for volume UP button

 {

 // decrease pulse width means increase color intensity

 if(red_intensity>5) red_intensity-=25;

 Serial.print("red intensity increased to ");

 i = 100-red_intensity*100/255; // convert it into 1 to 100%

 Serial.println(i); // display it on serial monitor
 
analogWrite(red,red_intensity);

 }

 else if(results.value==6292) // for volume down button

 {

 // increase pulse width means decrease color intensity

 if(red_intensity<255) red_intensity+=25;

 Serial.print("red intensity decreased to ");

 i= 100-red_intensity*100/255; // convert it into 1 to 100%

 Serial.println(i); // display it on serial monitor

 analogWrite(red,red_intensity);

 }

 else if(results.value==2205) // same as above for green color LED

 {

 if(green_intensity>5) green_intensity-=25;

 Serial.print("green intensity increased to ");

 i=100 - green_intensity*100/255;

 Serial.println(i);

 analogWrite(green,green_intensity);

 }

 else if(results.value==2199)

 {

 if(green_intensity<255) green_intensity+=25;
 
Serial.print("green intensity decreased to ");

 i=100 - green_intensity*100/255;

 Serial.println(i);

 analogWrite(green,green_intensity);

 }

 else if(results.value==6377) //same as above for blue color LED

 {

 if(blue_intensity>5) blue_intensity-=25;

 Serial.print("blue intensity increased to ");

 i=100 - blue_intensity*100/255;

 Serial.println(i);

 analogWrite(blue,blue_intensity);

 }

 else if(results.value==6378)

 {

 if(blue_intensity<255) blue_intensity+=25;

 Serial.print("blue intensity decreased to ");

 i=100 - blue_intensity*100/255;

 Serial.println(i);

 analogWrite(blue,blue_intensity);

 }

 delay(200); // wait for 200 ms

 irrecv.resume; // Receive the next value

 }

 }

###

Circuit diagrams

Circuit Diagram-Arduino-IR-Remte-Based-RGB-Bulb-Controller

Project video

Conteúdo Relacionado

A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
ESP32-CAM is a compact camera module that combines the...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.