#include #include #define LED_WHITE 5 #define LED_GREEN 6 #define LED_BLUE 10 #define LED_RED 9 #define IR_PIN 2 #define IR_PROTOCOL 1 #define IR_FILTER 0xF70000 #define IR_MASK 0xFF0000 #define IR_KEY_1 0xF720DF #define IR_KEY_2 0xF710EF #define IR_KEY_3 0xF730CF #define IR_KEY_4 0xF70000 // key is broken :-( #define IR_KEY_5 0xF728D7 #define IR_KEY_6 0xF7A05F #define IR_KEY_7 0xF7906F #define IR_KEY_8 0xF7B04F #define IR_KEY_9 0xF78877 #define IR_KEY_FLASH 0xF7D02F #define IR_KEY_STROBE 0xF7F00F #define IR_KEY_FADE 0xF7C837 #define IR_KEY_SMOOTH 0xF7E817 #define IR_KEY_DIM 0xF7807F #define IR_KEY_BRIGHT 0xF700FF #define IR_KEY_ALLON 0xF7C03F #define IR_KEY_ALLOFF 0xF740BF #define IR_KEY_LIGHT10 0xF7A857 #define IR_KEY_LIGHT11 0xF7609F #define IR_KEY_LIGHT12 0xF750AF #define IR_KEY_LIGHT13 0xF7708F #define IR_KEY_LIGHT14 0xF748B7 #define IR_KEY_LIGHT15 0xF76897 #define IR_KEY_LIGHT16 0xF7E01F int leds[] = {LED_WHITE, LED_GREEN, LED_BLUE, LED_RED}; int white = 0x01; 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); irrecv.enableIRIn(); // Start the receiver } void loop() { strip.loop(); if (irrecv.decode(&results)) { if (results.decode_type == IR_PROTOCOL) { if (results.value != 0xFFFFFFFF) { //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_FADE: strip.animateColorAdd(255, 0, 0, 100); strip.animateColorAdd(255, 255, 0, 100); strip.animateColorAdd( 0, 255, 0, 100); strip.animateColorAdd( 0, 255, 255, 100); strip.animateColorAdd( 0, 0, 255, 100); strip.animateColorAdd(255, 0, 255, 100); strip.animateStart(); break; case IR_KEY_DIM: white -= 0x10; if (white < 0x00) { white = 0x00; } analogWrite(LED_WHITE, white); break; case IR_KEY_BRIGHT: white += 0x10; if (white > 0xFF) { white = 0xFF; } analogWrite(LED_WHITE, white); break; default: Serial.print("proto: "); Serial.print(results.decode_type, DEC); Serial.print(" code: "); Serial.println(results.value, HEX); break; } } } irrecv.resume(); // Receive the next value } } // vim:filetype=c:ts=2