Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
120 min
Share

RGB led control using IR remote control

Controlling things remotely is a wonderful thing. Thanks to Arduino, you can control turning on and off lamps using an ir remote. You can also control the color of the lamp’s lighting.

Project Video

Overview

In this tutorial, we will learn how to control an RGB LED to light up different colors by pressing different buttons on an IR remote.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
RGB LED Common Cathode (3 Pack)
Get Item
Infrared Remote Control Kit
Get Item
Half-size Breadboard
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the ir sensor and the Arduino and the RGB led as shown in the image below.

Connections from the Arduino to the breadboard:

  • Arduino GND pin → Breadboard ground line

  • Arduino 5V pin → Breadboard 5V line

Connections from the RGB LED:

 • Red led pin→220-ohm resistor→ Arduino pin 3

 • Negative pin→ Breadboard ground line

  • Green led pin→ 220-ohm resistor → Arduino pin 5

  • Blue led pin→ 220-ohm resistor → Arduino pin 6

Connections from IR receiver to the Arduino:

  • IR receiver GND pin (- pin) → Breadboard ground line

  • IR receiver VCC pin (+ pin) → breadboard 5v line

  • IR receiver signal pin → Arduino pin 9

Coding

/*

Voltaat learn (http://learn.voltaat.com)

Link for full tutorial:

Tutorial: RGB led control using IR remote control!

The purpose of this sketch is to control an RGB LED to light up different colors

by pressing different buttons on an IR remote.

Connections from the Arduino to the breadboard:

• Arduino GND pin → Breadboard ground line

• Arduino 5V pin → Breadboard 5V line

Connections from the RGB LED:

• Red led pin→220-ohm resistor→ Arduino pin 3

• Negative pin→ Breadboard ground line

• Green led pin→ 220-ohm resistor → Arduino pin 5

• Blue led pin→ 220-ohm resistor → Arduino pin 6

Connections from IR receiver to the Arduino:

• IR receiver GND pin (- pin) → Breadboard ground line

• IR receiver VCC pin (+ pin) → breadboard 5v line

• IR receiver signal pin → Arduino pin 9

*/

#include "IRremote.h"

const int receivePin =9;

IRrecv irrecv(receivePin);//Create the receiver object

decode_results results; //define code to charater mapping for remote control keys

const int RED = 3;

const int BLUE = 5;

const int GREEN = 6;

void setup()

{

 Serial.begin(9600);

 irrecv.enableIRIn();//begin the receiving process

 pinMode(RED,OUTPUT);

 pinMode(BLUE,OUTPUT);

 pinMode(GREEN,OUTPUT);

 Serial.println("a]to turn on RED light press 1\nb]to turn on BLUE light press 2\nc]to turn on BLUE light press 3");

 

}

void loop()

{

if (irrecv.decode(&results))////this checks to see if a code has been received

 {

   switch (results.value)//The results from each button press can be found by calling the value() method

   {

     case 0xFFA25D://HEX code for button 1

 digitalWrite(RED,HIGH);

 digitalWrite(GREEN,LOW);

 digitalWrite(BLUE,LOW);

 Serial.println("RED");

       break;

     case 0xFF629D://HEX code for button 2

       digitalWrite(RED,LOW);

 digitalWrite(GREEN,HIGH);

 digitalWrite(BLUE,LOW);

 Serial.println("GREEN");

       break;

     case 0xFFE21D://HEX code for button 3

       digitalWrite(RED,LOW);

 digitalWrite(GREEN,LOW);

 digitalWrite(BLUE,HIGH);

 Serial.println("BLUE");

       break;

      case 0xFF22DD:

       digitalWrite(RED,LOW);

 digitalWrite(GREEN,LOW);

 digitalWrite(BLUE,LOW);

       Serial.println("OFF");

       break;

     default:

       Serial.print("Unrecognized code received: 0x");

       Serial.println(results.value, HEX);

       break;        

   }  

 

   irrecv.resume();// reset the receiver and prepare it to receive another code.  

 

}

 }

Testing it Out

Once you’ve uploaded the code to the Arduino board, you will find that you can control the RGB LED to light up different colors by pressing different buttons on the IR remote

Resources

No items found.