implemented strobe mode
This commit is contained in:
parent
cd50362684
commit
fb95099bd5
@ -35,20 +35,26 @@
|
||||
#define IR_KEY_LIGHT15 0xF76897
|
||||
#define IR_KEY_LIGHT16 0xF7E01F
|
||||
|
||||
int leds[] = {LED_WHITE, LED_GREEN, LED_BLUE, LED_RED};
|
||||
#define MODE_OFF 0x00
|
||||
#define MODE_CONSTANT 0x01
|
||||
#define MODE_FLASH 0x02
|
||||
#define MODE_STROBE 0x03
|
||||
#define MODE_FADE 0x04
|
||||
#define MODE_SMOOTH 0x05
|
||||
|
||||
int white = 0x01;
|
||||
int mode = MODE_CONSTANT;
|
||||
boolean strobe = false;
|
||||
|
||||
IRrecv irrecv(IR_PIN);
|
||||
decode_results results;
|
||||
simtronyx_RGB_LED strip(LED_RED, LED_GREEN, LED_BLUE);
|
||||
|
||||
void setup() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pinMode(leds[i], OUTPUT);
|
||||
analogWrite(leds[i], 0x00);
|
||||
}
|
||||
analogWrite(LED_WHITE, white);
|
||||
Serial.begin(9600);
|
||||
pinMode(LED_WHITE, OUTPUT);
|
||||
analogWrite(LED_WHITE, white);
|
||||
strip.setRGB(0x00, 0x00, 0x00);
|
||||
irrecv.enableIRIn(); // Start the receiver
|
||||
}
|
||||
|
||||
@ -60,16 +66,31 @@ void loop() {
|
||||
//if (results.value & IR_MASK == IR_FILTER) {
|
||||
Serial.println(results.value);
|
||||
switch (results.value) {
|
||||
case IR_KEY_1: strip.animateStop(); analogWrite(LED_RED, 0x00); break;
|
||||
case IR_KEY_2: strip.animateStop(); analogWrite(LED_GREEN, 0x00); break;
|
||||
case IR_KEY_3: strip.animateStop(); analogWrite(LED_BLUE, 0x00); break;
|
||||
case IR_KEY_4: strip.animateStop(); analogWrite(LED_RED, 0x80); break;
|
||||
case IR_KEY_5: strip.animateStop(); analogWrite(LED_GREEN, 0x80); break;
|
||||
case IR_KEY_6: strip.animateStop(); analogWrite(LED_BLUE, 0x80); break;
|
||||
case IR_KEY_7: strip.animateStop(); analogWrite(LED_RED, 0xFF); break;
|
||||
case IR_KEY_8: strip.animateStop(); analogWrite(LED_GREEN, 0xFF); break;
|
||||
case IR_KEY_9: strip.animateStop(); analogWrite(LED_BLUE, 0xFF); break;
|
||||
case IR_KEY_1: mode = MODE_CONSTANT; strip.animateStop(); strip.setR(0x00); break;
|
||||
case IR_KEY_2: mode = MODE_CONSTANT; strip.animateStop(); strip.setG(0x00); break;
|
||||
case IR_KEY_3: mode = MODE_CONSTANT; strip.animateStop(); strip.setB(0x00); break;
|
||||
case IR_KEY_4: mode = MODE_CONSTANT; strip.animateStop(); strip.setR(0x80); break;
|
||||
case IR_KEY_5: mode = MODE_CONSTANT; strip.animateStop(); strip.setG(0x80); break;
|
||||
case IR_KEY_6: mode = MODE_CONSTANT; strip.animateStop(); strip.setB(0x80); break;
|
||||
case IR_KEY_7: mode = MODE_CONSTANT; strip.animateStop(); strip.setR(0xFF); break;
|
||||
case IR_KEY_8: mode = MODE_CONSTANT; strip.animateStop(); strip.setG(0xFF); break;
|
||||
case IR_KEY_9: mode = MODE_CONSTANT; strip.animateStop(); strip.setB(0xFF); break;
|
||||
case IR_KEY_STROBE:
|
||||
mode = MODE_STROBE;
|
||||
strip.animateStop();
|
||||
strip.setRGB(0x00, 0x00, 0x00);
|
||||
break;
|
||||
case IR_KEY_FADE:
|
||||
mode = MODE_FADE;
|
||||
strip.animateColorsClear();
|
||||
strip.animateColorAdd(255, 0, 0, 100);
|
||||
strip.animateColorAdd( 0, 255, 0, 100);
|
||||
strip.animateColorAdd( 0, 0, 255, 100);
|
||||
strip.animateStart();
|
||||
break;
|
||||
case IR_KEY_SMOOTH:
|
||||
mode = MODE_SMOOTH;
|
||||
strip.animateColorsClear();
|
||||
strip.animateColorAdd(255, 0, 0, 100);
|
||||
strip.animateColorAdd(255, 255, 0, 100);
|
||||
strip.animateColorAdd( 0, 255, 0, 100);
|
||||
@ -103,6 +124,14 @@ void loop() {
|
||||
}
|
||||
irrecv.resume(); // Receive the next value
|
||||
}
|
||||
if (mode == MODE_STROBE) {
|
||||
strobe = !strobe;
|
||||
if (strobe) {
|
||||
analogWrite(LED_WHITE, white);
|
||||
} else {
|
||||
analogWrite(LED_WHITE, 0x00);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim:filetype=c:ts=2
|
||||
|
Loading…
Reference in New Issue
Block a user