Basically what i am trying to do is use an ir remote to turn an rgb on/off and have a few preset colors as well as being able to increase/decrease red/green/blue independently. I don't know much about C/C++ so this is really hard to troubleshoot.
#include <IRremote.h>
int rbright;
int gbright;
int bbright;
int before;
int RECV_PIN=12; //data out of IR receiver connects to pin 12
int redPin=11;
int greenPin=10;
int bluePin=9;
int steps=5;
IRrecv irrecv(RECV_PIN);
decode_results results;
//uncomment this line if using a Common Anode LED
#define COMMON_ANODE
void setup()
{
before=0;
rbright=80;
gbright=0;
bbright=80;
irrecv.enableIRIn(); // start the receiver
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
if (irrecv.decode(&results)) {
if (results.value==B54A3AC5){ //Code to turn the LED ON/OFF
if(before==0){ // if the LED was turned off, then we turn it on
digitalWrite(redpin,HIGH);
digitalWrite(greenpin,HIGH);
digitalWrite(bluepin,HIGH);
before=1; //LED is now turned on
}
else{
digitalWrite(redpin,LOW);
digitalWrite(greenpin,LOW);
digitalWrite(bluepin,LOW); //if the LED was turned on, then we turn it off
before=0;
}
}
if (results.value==B54A8A75 && before==1){ //Code to decrease the red
if(rbright-255/steps<0){
analogWrite(redpin,rbright);
}
else{
rbright=rbright-255/steps;
analogWrite(redpin,rbright);
}
}
if (results.value==B54A7A85 && before==1){ //Code to increase the red
if(rbright+255/steps>255){
analogWrite(redpin,rbright);
}
else{
rbright=rbright+255/steps;
analogWrite(redpin,rbright);
}
}
if (results.value==B54AB24D && before==1){ //Code to decrease the green
if(gbright-255/steps<0){
analogWrite(greenpin,gbright);
}
else{
gbright=gbright-255/steps;
analogWrite(greenpin,gbright);
}
}
if (results.value==B54A32CD && before==1){ //Code to increase the green
if(gbright+255/steps>255){
analogWrite(greenpin,gbright);
}
else{
gbright=gbright+255/steps;
analogWrite(greenpin,gbright);
}
}
if (results.value==B54A0AF5 && before==1){ //Code to decrease the blue
if(bbright-255/steps<0){
analogWrite(bluepin,bbright);
}
else{
bbright=bbright-255/steps;
analogWrite(bluepin,bbright);
}
}
if (results.value==B54ACA35 && before==1){ //Code to increase the blue
if(bbright+255/steps>255){
analogWrite(bluepin,bbright);
}
else{
bbright=bbright+255/steps;
analogWrite(bluepin,bbright);
}
}
if (results.value==B54AA956 && before==1){ //Code yellow
setColor(255, 255, 0);
}
if (results.value==B54A2AD5 && before==1){ //Code purple
setColor(80, 0, 80);
}
if (results.value==B54AEA15 && before==1){ //Code aqua
setColor(0, 255, 255);
}
irrecv.resume();
}
void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
The errors i get are
rgbcontrolir_ino.ino: In function ‘void loop()’:
rgbcontrolir_ino.ino:35:24: error: ‘B54A3AC5’ was not declared in this scope
rgbcontrolir_ino.ino:37:20: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:38:20: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:39:20: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:43:20: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:44:20: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:45:20: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:48:22: error: ‘B54A8A75’ was not declared in this scope
rgbcontrolir_ino.ino:50:19: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:54:17: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:56:22: error: ‘B54A7A85’ was not declared in this scope
rgbcontrolir_ino.ino:58:19: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:62:17: error: ‘redpin’ was not declared in this scope
rgbcontrolir_ino.ino:64:22: error: ‘B54AB24D’ was not declared in this scope
rgbcontrolir_ino.ino:66:19: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:70:17: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:72:22: error: ‘B54A32CD’ was not declared in this scope
rgbcontrolir_ino.ino:74:19: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:78:17: error: ‘greenpin’ was not declared in this scope
rgbcontrolir_ino.ino:80:22: error: ‘B54A0AF5’ was not declared in this scope
rgbcontrolir_ino.ino:82:19: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:86:17: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:88:22: error: ‘B54ACA35’ was not declared in this scope
rgbcontrolir_ino.ino:90:19: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:94:17: error: ‘bluepin’ was not declared in this scope
rgbcontrolir_ino.ino:96:22: error: ‘B54AA956’ was not declared in this scope
rgbcontrolir_ino.ino:100:24: error: ‘B54A2AD5’ was not declared in this scope
rgbcontrolir_ino.ino:104:24: error: ‘B54AEA15’ was not declared in this scope
rgbcontrolir_ino.ino:112:5: error: a function-definition is not allowed here before ‘{’ token
rgbcontrolir_ino.ino:121:5: error: expected ‘}’ at end of input