Hello,
I've posted about this project before but had to take time to scale back the complexity of the project as this is my first arduino project/rodeo.
I decided to go with IR instead of voice activation because my Veear voice recognition board was giving me problems and I decided reluctantly that I was in WAY over my head.
I have an arduino UNO that I'm trying to remotely control a relay (Powerswitch Tail II (which will be connected to a water pump)), as well as a 5m string of RGB LED's.
This is a list of everything that I am using (or at least trying to use):
-Arduino UNO R3
-Breadboard
-Grove Base Shield
-Grove LED Strip Driver
-5m RGB LED strip
-12v power supply for LED's
-PowerSwitch Tail II
-IR sensor
-24 multi-color-button remote (bought offline with an LED screw in bulb which works on its own very well making me very upset )
If you look at the picture of the remote control which I've attached you can see the layout.
End goal is to be able to:
-press "ON" and have the relay switch on power to the water pump.
-press any of the color buttons and have the LED's switch to that color (preferably fade but from reading here that is an absolute nightmare so a hard color change will have to do)
-press "OFF" and have everything turn off.
-it would also be nice if I could figure out a way to press "FADE" and have a random color display but I'm well aware that beggars can't be choosers.
I found a code for a remote controlled RGB LED here: Arduino RGB led managed by remote control other than it being in another language, it's what I think I've been looking for. I changed the button coding for my remote (which was basically the same except for one or two buttons.
The way I have it all hooked up now, I have the Grove Base shield attached and the universal 4 pin cable connected to the LED driver. I don't know if there is a special library that I have to include for the base shield bc the sample code on the base shield's wiki page is "Demo code ()" which isn't entirely helpful. The LED strip will turn on but they won't change color. I opened up the serial monitor and the arduino is receiving the IR signal and the monitor puts out what looks to be the correct RGB values but the LED's won't change color.
The relay will turn off when I press "ON" which is the opposite of the desired button push.
Basically I've been working on this project for a year and a half and I feel like I've improved my arduino knowledge by leaps and bounds but I've got to a point where I need to reach out for help again as I'm not finding the answers I need already in the forums and my girlfriend is getting PO'd because I've had the baseboard ripped off of the walls in the foyer for the entire time :D.
Any help will be GREATLY appreciated!
Here's my code (be gentle...I know I've probably slaughtered it)
#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 = 3;
int R_PIN = 9;
int G_PIN = 11;
int B_PIN = 10;
int RELAY_PIN = 7;
#define ON 0XFFE01F
#define OFF 0xFF609F
#define BRIGHTNESS_UP 0xFFA05F
#define BRIGHTNESS_DOWN 0xFF20DF
#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(RELAY_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 : digitalWrite: r,0 ; g,0 ; 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 : digitalWrite (7, HIGH);
}
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
}
}