IR Controlled RGB LED

Introduction: IR Controlled RGB LED

This will allow full RGB control of an RGB LED (aprox. 1.6 million colours). This is merely a proof of concept; real applications might be to connect and RGB LED srtip for lighting your room or your PC.

Parts list:

  • Arduino UNO Rev3
  • RGB LED (or RGB LED strip / other RGB display)
  • IR remote & receiver
  • 3 220R resistors
  • Prototyping board (I used a prototyping shield as well)
  • 6 jumper cables

Here I use the bottom two rows of digits on my remote (4-9) to control the intensity of each colour.

Step 1: Wiring

You may need to play around with the pins used. I had to change mine until I found some that work. I think there is a bug with the IR library I used; I will need to experiment more with this.

Step 2: Code

First, you will need to install the IR library: https://github.com/z3t0/Arduino-IRremote

Find the code here: https://gist.github.com/Marcel-Robitaille/bebb855812428b19bb2c

You may need to change the codes depending on your remote.

#include <./IRremote.h>
int pinR = 9; int pinG = 6; int pinB = 5; int pinSignal = 11;

IRrecv irrecv(pinSignal); decode_results results;

long codes[6]= { 0xFD28D7, //4 0xFD18E7, //7 0xFDA857, //5 0xFD9867, //8 0xFD6897, //6 0xFD58A7 //9 }; int valR = 0; int valG = 0; int valB = 0;

void setup(){ Serial.begin(9600); irrecv.enableIRIn();

pinMode(pinR, OUTPUT); pinMode(pinG, OUTPUT); pinMode(pinB, OUTPUT);

}

void loop(){ if(irrecv.decode(&results)){ if(results.value == codes[0] && valR < 255){ valR++; }

else if(results.value == codes[1] && valR > 0){ valR--; }

else if(results.value == codes[2] && valG < 255){ valG++; }

else if(results.value == codes[3] && valG > 0){ valG--; }

else if(results.value == codes[4] && valB < 255){ valB++; }

else if(results.value == codes[5] && valB > 0){ valB--; } display(valR, valG, valB); Serial.print("Red: "); Serial.println(valR); Serial.print("Green: "); Serial.println(valG); Serial.print("Blue: "); Serial.println(valB); Serial.println(""); irrecv.resume(); } }

void display(int red, int green, int blue){ analogWrite(pinR, constrain(red, 0, 255)); analogWrite(pinG, constrain(green, 0, 255)); analogWrite(pinB, constrain(blue, 0, 255)); }

Attachments

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest

Be the First to Share

    Recommendations

    • Home Decor Challenge

      Home Decor Challenge
    • Furniture Contest

      Furniture Contest
    • Toys & Games Contest

      Toys & Games Contest

    15 Comments

    0
    tankapotamus
    tankapotamus

    5 months ago

    You should add some notes to your code. Help the beginners learn (and debug!).

    0
    CraigH5
    CraigH5

    Tip 1 year ago

    Hi.
    Thanks for the 'Ible'... I had a few issues but got it working.
    This is what I had to do if anyone else gets stuck.
    My remote was responding in the serial monitor but kept returning RGB all zero.
    It turned out my remote codes were
    long codes[6]= {
    0xFF10EF, //4
    0xFF42BD, //7
    0xFF38C7, //5
    0xFF4AB5, //8
    0xFF5AA5, //6
    0xFF52AD //9
    };
    After changing these values it worked fine.
    I used the info from this site to find my remote codes... http://www.circuitbasics.com/arduino-ir-remote-receiver-tutorial/
    I also changed the code to increase the colours by 10 per button press with the following bit of code...
    if(results.value == codes[0] && valR < 255){
    valR=valR+10;

    Thanks for the inspiration to finally do something with the remote and sensor I bought over 5 years ago :)

    0
    ErwinM5
    ErwinM5

    2 years ago

    Ik gebruik een common anode rgb led, wat moet ik aan het programma veranderen?

    Mijn arduino is een arduino Nano, zou dit mijn probleem zijn, ik zie de kleuren niet veranderen

    Can you help me please


    Kind regards

    0
    Ahmed alhadrami
    Ahmed alhadrami

    3 years ago

    it is not working

    I think the remote control or the reseiver

    0
    Fallenalien22
    Fallenalien22

    Reply 3 years ago

    It is impossible for me to help you without more information. Double check your wiring. Make sure everything compiled correctly.

    0
    TravisS92
    TravisS92

    4 years ago

    i get an error. exit status 1

    error compiling for board

    0
    Fallenalien22
    Fallenalien22

    Reply 4 years ago

    Make sure you have the correct board selected in tools.

    0
    Onur075207
    Onur075207

    5 years ago

    this is usefull thanx for share this

    0
    Fallenalien22
    Fallenalien22

    Reply 5 years ago

    Glad you found it useful.

    0
    non-conformist
    non-conformist

    5 years ago

    Great idea, great explanation!

    0
    Fallenalien22
    Fallenalien22

    Reply 5 years ago

    Thanks mom

    0
    DamianTheGreat
    DamianTheGreat

    5 years ago

    Awesome tutorial, very professional.

    0
    Fallenalien22
    Fallenalien22

    Reply 5 years ago

    Thanks.

    0
    seamster
    seamster

    5 years ago

    Very cool idea. Nice and simple too!

    0
    Fallenalien22
    Fallenalien22

    Reply 5 years ago

    Thank you. If you liked it, please vote for me in the "Arduino all the things" contest.