Pages: [1]   Go Down
Author Topic: Controlling RGB lights wirelessly by use of a remote control?  (Read 2714 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 1
Posts: 282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What would I need to know to get started with controlling RGB lights wirelessly by use of a remote control? smiley-red
Logged

peace*&^

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5239
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.arduino.cc/playground/Code/InfraredReceivers
Logged

Alicante (Spain)
Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

See this project: http://arduino-cool.blogspot.com.es/2012/09/arduino-rgb-led-managed-by-remote.html
I used the IRRemote library and a cheap remote control .
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the ULN2003A IC used for in that example?  What if I want to use a universal remote control with use of Sony protocol instead of using a ED618 remote with use of NEC protocol?  Is there a specific IR receiver to buy if going with the universal remote control?  My guess would be a matching frequency of # KHz or GHz.
Logged

peace*&^

Alicante (Spain)
Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The ULN2003A is a driver for manage the power RGB led, in the example is a 5W led.
The irremote library support this prortocols :NEC, SONY, RC5, RC6, DISH, SHARP, PANASONIC, JVC, SANYO and MITSUBISHI.
The IR receiver normally are 36 to 38KHz, depend of remote control, but are not critical.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!  What distance can I expect to get from a universal remote control purchased from Wal-Mart or Lowes?  How does the 4.7 microFarads capacitor come into play in your circuit? smiley-grin
Logged

peace*&^

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5239
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How does the 4.7 microFarads capacitor come into play in your circuit?

This is a decoupling capacitor, which stabilizes the power supplied to your device.

Quote
What distance can I expect to get from a universal remote control purchased from Wal-Mart or Lowes?

Depends on many factors but usually expect a few meters.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The ULN2003A is a driver for manage the power RGB led, in the example is a 5W led.

That is a powerful led then.  if i were using a simple 5mm RGB led with supply of 4V would I still need that IC?  I see on ebay the color rgb remote control is sold with the IR receiver.  What if I went with the more complex remote, would the sketch be any different?  I see some sell with "gift" 4 pin male connectors having wire output.  Seems usefully if i were going to use the purchased IR.  Also there is another item sold with remote and IR Controller.  That also seems useful.  What are the perks of each?

http://www.ebay.com/itm/44-Key-IR-Remote-Controller-For-RGB-5050-LED-Light-Strip-Five-outputs-gift-/170882418628?pt=US_Lighting_Parts_and_Accessories&hash=item27c962c7c4

http://www.ebay.com/itm/DC-12V-24V-12A-144W-24Key-IR-Remote-Controller-For-RGB-SMD-5050-3528-LED-Strip-/221147438087?pt=US_Lighting_Parts_and_Accessories&hash=item337d6a1c07
Logged

peace*&^

Alicante (Spain)
Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
if i were using a simple 5mm RGB led with supply of 4V would I still need that IC?
For a 5 mm LED, no driver need. You can use the output from the Arduino

Rreceivers who are indicating they do not need any circuit, only one resistor for LEDs, because the outputs are 12 V.
Logged

CO
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm a Noob as you can see by my lofty 17 posts and 0 karma so I wanted to ask if it's kosher to jump into this thread for some help on the same topic or if I should start a new thread?
Logged

CO
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll just go for it because encryptor might be able to get something from it as well if he hasn't already finished his project up.

I'm building a waterfall for my foyer and I want it to be remote controlled. Arduino-guay, your code is EXACTLY what I've been looking for. I actually have the exact same remote that you used in your project. The codes were basically all the same too.

I wanted to add a function to your code and that would be to turn the water pump on and off with the remote as well. The pump is run off of a relay extension cord that I got so that I wouldn't have to cut any wires. I got an error that I attached. Here is the code that I changed a little:
Code:
#include <IRremote.h>
#include <IRremoteInt.h>

/*
*  Control remoto de LED RGB
*  Ejemplo de como hacer variar el color y el brillo con un led RGB 
*  con un mando a distancia.
*  Se utiliza un receptor de infrarrojos del tipo TSOP1738
*  Autor: Jose Daniel Herrera
*  Fecha: 28/08/2012
*  http://arduino-guay.blogspot.com.es
*/
 

 
int RECV_PIN = 8;
int R_PIN = 9;
int G_PIN = 6;
int B_PIN = 10;
int WTR_PIN = 7;
 
#define ON                0XFFE01F
#define OFF               0xFF609F
#define BRIGHTNESS_UP     0xFFA05F
#define BRIGHTNESS_DOWN   0xFF20DG
#define FLASH             0xFFF00F
#define STROBE            0xFFE817
#define FADE              0xFFD827
#define SMOOTH            0xFFC837
 
#define RED               0xFF906F
#define GREEN             0XFF10EF
#define BLUE              0xFF50AF
#define WHITE             0xFFD02F
 
#define ORANGE            0xFFB04F
#define YELLOW_DARK       0xFFA857
#define YELLOW_MEDIUM     0xFF9867
#define YELLOW_LIGHT      0xFF8877
 
#define GREEN_LIGHT       0XFF30CF
#define GREEN_BLUE1       0XFF28D7
#define GREEN_BLUE2       0XFF18E7
#define GREEN_BLUE3       0XFF08F7
 
#define BLUE_RED          0XFF708F
#define PURPLE_DARK       0XFF6897
#define PURPLE_LIGHT      0XFF58A7
#define PINK              0XFF48B7
 
#define INCREMENTO 10
 
unsigned long rgb = 0;
byte r,g,b;
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
 
void setup()
{
  irrecv.enableIRIn(); // Inicializamos el receptor
  Serial.begin(9600);
  pinMode(R_PIN, OUTPUT);   
  pinMode(G_PIN, OUTPUT);   
  pinMode(B_PIN, OUTPUT);
  pinMode(WTR_PIN, OUTPUT); 
}
 
 
void variar (byte* color, char valor) {
    if (valor > 0) {
        if ( *color + valor <= 255) {
            *color += valor;
        } else {
            *color = 255;
        }
    } else {
        if (*color + valor >= 0) {
            *color += valor;
        } else {
            *color = 0;
        }
  }
}
 
void RGB(unsigned long valor) {
   r = valor >> 16;
   g = (valor >> 8) & 0xFF;
   b = valor & 0xFF;
}
 
void loop() {
  if (irrecv.decode(&results)) {
    if ( results.value != 0xFFFFFFFF) {
      switch (results.value) {
           case BRIGHTNESS_UP :
               variar (&r, INCREMENTO);
               variar (&g, INCREMENTO);
               variar (&b, INCREMENTO);
               break;
           case BRIGHTNESS_DOWN :
               variar (&r, -INCREMENTO);
               variar (&g, -INCREMENTO);
               variar (&b, -INCREMENTO);
               break;
           case OFF :
              r = g = b = 0; 7,LOW;
               break;   
           case RED           : RGB(0x00FF0000); break;
           case GREEN         : RGB(0x0000FF00); break;
           case BLUE          : RGB(0x000000FF); break;
           case WHITE         : RGB(0x00FFFFFF); break;
           case ORANGE        : RGB(0x00FF7F00); break;
           case YELLOW_DARK   : RGB(0x00FFAA00); break;
           case YELLOW_MEDIUM : RGB(0x00FFD400); break;
           case YELLOW_LIGHT  : RGB(0x00FFFF00); break;
           case GREEN_LIGHT   : RGB(0x0000FFAA); break;
           case GREEN_BLUE1   : RGB(0x0000FFFF); break;
           case GREEN_BLUE2   : RGB(0x0000AAFF); break;
           case GREEN_BLUE3   : RGB(0x000055FF); break;
           case BLUE_RED      : RGB(0x00000080); break;
           case PURPLE_DARK   : RGB(0x003F0080); break;
           case PURPLE_LIGHT  : RGB(0x007A00BF); break;
           case PINK          : RGB(0x00FF00FF); break;
           case ON            :   7,HIGH; break;
         }
      Serial.println(results.value, HEX);
      Serial.println(r,DEC);
      Serial.println(g, DEC);
      Serial.println(b, DEC);
      analogWrite(R_PIN,r);
      analogWrite(G_PIN,g);
      analogWrite(B_PIN,b);
    }
    irrecv.resume(); // Receive the next value
  }
}

Like I said before, I'm brand new to this. I've been working on this for a long time now and I'm making progress so I'm excited again.

Thanks for any help.


* waterfall error1.PNG (2.45 KB, 527x124 - viewed 34 times.)
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5239
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#define BRIGHTNESS_DOWN   0xFF20DG

"G" is not a valid digit of a hex number.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My code:

Code:
/*
*  Remote Control A RGB LED   
*  Example of how to make the color and brightness of an RGB led vary with a remote control.
*  This project utilizes a 38kHz IR reciever from RadioShack - 
*  Author: Jose Daniel Herrera
*  Modified by: Evan Johnson
*  Date Created: 08/28/2012
*  Date Modified: 12/11/2012
*  http://arduino-guay.blogspot.com.es
*/
 
#include <IRremote.h>

int RECV_PIN = 8;
int R_PIN = 9;
int G_PIN = 6;
int B_PIN = 10;
 
 
//Define these descriptions to the value displayed in serial monitor for which you want them to match up.
//Try Sony TV protocol first which is decimal, not hexidecimal like shown here.
 
//#define ON                0X
#define OFF               0xA90         
#define BRIGHTNESS_UP     0x490  //volume up       
#define BRIGHTNESS_DOWN   0xC90  //volume down       
//#define FLASH             0x
//#define STROBE            0x     
//#define FADE              0x           
//#define SMOOTH            0x           

#define RED               0x10     //BUTTON 1
#define GREEN             0X810    //BUTTON 2
#define BLUE              0x410    //BUTTON 3   
#define WHITE             0xC10    //BUTTON 4
 
#define ORANGE            0x210    //BUTTON 5
#define YELLOW_DARK       0xA10    //BUTTON 6
#define YELLOW_MEDIUM     0x610    //BUTTON 7
#define YELLOW_LIGHT      0xE10    //BUTTON 8
 
#define GREEN_LIGHT       0X110    //BUTTON 9
#define GREEN_BLUE1       0X910    //BUTTON 0   
#define GREEN_BLUE2       0X5CE9   //PERIOD (.)   
#define GREEN_BLUE3       0XD10    //ENT

#define BLUE_RED          0X90     //CHANNEL +
#define PURPLE_DARK       0X890    //CHANNEL -       
#define PURPLE_LIGHT      0X290    //MUTING     
#define PINK              0XDD0    //RECALL     

#define INCREMENT 10
 
unsigned long rgb = 0;
byte r,g,b;
 
IRrecv irrecv(RECV_PIN);
 
decode_results results;
 
//*******************************************************
//*******************************************************
 
void setup()
{
  irrecv.enableIRIn(); // Inicializamos el receptor
  Serial.begin(9600);
  pinMode(R_PIN, OUTPUT);   
  pinMode(G_PIN, OUTPUT);   
  pinMode(B_PIN, OUTPUT);
  pinMode(RECV_PIN, INPUT);
}

//*******************************************************
//*******************************************************
 
void loop()
{
  //if there is input  to decode from the remote control
  if (irrecv.decode(&results))
  {
    //if the frequency is not high (high signal means no remote pulling down frequency)
    if (results.value != 0xFFFFFFFF)
    {
      // see which button was pressed on the remote
      switch (results.value)
      {
           //user pressed volume +
           case BRIGHTNESS_UP :
               vary (&r, INCREMENT);
               vary (&g, INCREMENT);
               vary (&b, INCREMENT);
               break;
           
           //user pressed volume -
           case BRIGHTNESS_DOWN :
               vary (&r, -INCREMENT);
               vary (&g, -INCREMENT);
               vary (&b, -INCREMENT);
               break;
           
           //user pressed on/off button
           case OFF :
               r = g = b = 0;
               break;   
           
           case RED           : RGB(0x00FF0000); break;
           case GREEN         : RGB(0x0000FF00); break;
           case BLUE          : RGB(0x000000FF); break;
           case WHITE         : RGB(0x00FFFFFF); break;
           case ORANGE        : RGB(0x00FF0A00); break; //FF->0A
           case YELLOW_DARK   : RGB(0x00FFAA00); break;
           case YELLOW_MEDIUM : RGB(0x00FFD400); break;
           case YELLOW_LIGHT  : RGB(0x00FFFF00); break;
           case GREEN_LIGHT   : RGB(0x0000FFAA); break;
           case GREEN_BLUE1   : RGB(0x00000AFF); break; //FF->0A
           case GREEN_BLUE2   : RGB(0x0000AAFF); break;
           case GREEN_BLUE3   : RGB(0x000055FF); break;
           case BLUE_RED      : RGB(0x00000080); break;
           case PURPLE_DARK   : RGB(0x003F0080); break;
           case PURPLE_LIGHT  : RGB(0x007A00BF); break;
           case PINK          : RGB(0x00FF00FF); break;
      }
     
      //Print report to serial monitor
      Serial.print("Result frequency of remote button pressed: ");
      Serial.println(results.value, HEX);
      Serial.print("Red Value: ");
      Serial.println(r,DEC);
      Serial.print("Green Value: ");
      Serial.println(g, DEC);
      Serial.print("Blue Value: ");
      Serial.println(b, DEC);
     
      //Write byte values to RGB led
      analogWrite(R_PIN,r);
      analogWrite(G_PIN,g);
      analogWrite(B_PIN,b);
    }
    // Receive the next value
    irrecv.resume();
  }
}

//**********************************************************
//**********************************************************

//1) vary the led's color based by INCREMENT value of 10
void vary (byte* color, char value) {
    if (value > 0) {
        if ( *color + value <= 255) {
            *color += value;
        } else {
            *color = 255;
        }
    } else {
        if (*color + value >= 0) {
            *color += value;
        } else {
            *color = 0;
        }
  }
}

//******************************************
void RGB(unsigned long value) {
   r = value >> 16;
   g = (value >> 8) & 0xFF;
   b = value & 0xFF;
}
Logged

peace*&^

Pages: [1]   Go Up
Jump to: