im trying to have the one key count to three. first count sets it to 100% brightness then 50% then 10% for R then reset when pressed a forth time and the same with the two and three key (two changes G brightness then three changes B) then the power button to set R, G and B to low but high when pressed a second time then repeat
heres the code, thank you
#include <DIYables_IRcontroller.h> // DIYables_IRcontroller library
#define IR_RECEIVER_PIN 7 // The Arduino pin connected to IR controller
DIYables_IRcontroller_21 irController(IR_RECEIVER_PIN, 200); // debounce time is 200ms
const int R = 5;
const int G = 6;
const int B = 4;
int PowerCounter = 0;
int PowerState = 0;
int LastPowerState = 0;
void setup() {
Serial.begin(9600);
irController.begin();
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
}
void loop() {
Key21 key = irController.getKey();
if (key != Key21::NONE) {
switch (key) {
case Key21::KEY_CH_MINUS:
Serial.println("Power");
// TODO: YOUR CONTROL
break;
case Key21::KEY_CH:
Serial.println("+");
// TODO: YOUR CONTROL
break;
case Key21::KEY_CH_PLUS:
Serial.println("Func");
// TODO: YOUR CONTROL
break;
case Key21::KEY_PREV:
Serial.println("<<");
// TODO: YOUR CONTROL
break;
case Key21::KEY_NEXT:
Serial.println(">||");
// TODO: YOUR CONTROL
break;
case Key21::KEY_PLAY_PAUSE:
Serial.println(">>");
// TODO: YOUR CONTROL
break;
case Key21::KEY_VOL_MINUS:
Serial.println("CH_Down");
// TODO: YOUR CONTROL
break;
case Key21::KEY_VOL_PLUS:
Serial.println("-");
// TODO: YOUR CONTROL
break;
case Key21::KEY_EQ:
Serial.println("CH_Up");
// TODO: YOUR CONTROL
break;
case Key21::KEY_100_PLUS:
Serial.println("EQ");
// TODO: YOUR CONTROL
break;
case Key21::KEY_200_PLUS:
Serial.println("ST");
// TODO: YOUR CONTROL
break;
case Key21::KEY_0:
Serial.println("0");
// TODO: YOUR CONTROL
break;
case Key21::KEY_1:
Serial.println("1");
// TODO: YOUR CONTROL
analogWrite(R, 255);
break;
case Key21::KEY_2:
Serial.println("2");
// TODO: YOUR CONTROL
break;
case Key21::KEY_3:
Serial.println("3");
// TODO: YOUR CONTROL
break;
case Key21::KEY_4:
Serial.println("4");
// TODO: YOUR CONTROL
break;
case Key21::KEY_5:
Serial.println("5");
// TODO: YOUR CONTROL
break;
case Key21::KEY_6:
Serial.println("6");
// TODO: YOUR CONTROL
break;
case Key21::KEY_7:
Serial.println("7");
// TODO: YOUR CONTROL
break;
case Key21::KEY_8:
Serial.println("8");
// TODO: YOUR CONTROL
break;
case Key21::KEY_9:
Serial.println("9");
// TODO: YOUR CONTROL
break;
default:
Serial.println("WARNING: undefined key:");
break;
}
}
}