Created
July 15, 2014 13:30
-
-
Save tekk/c84f36485e22e7e4e7bd to your computer and use it in GitHub Desktop.
IRMood
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <IRremote.h> | |
| int RECV_PIN = A0; | |
| IRrecv irrecv(RECV_PIN); | |
| decode_results results; | |
| boolean red, green, blue, on; | |
| void setup() | |
| { | |
| red = green = blue = false; | |
| on = true; | |
| pinMode(9, OUTPUT); | |
| pinMode(8, OUTPUT); | |
| pinMode(7, OUTPUT); | |
| digitalWrite(9, HIGH); | |
| digitalWrite(8, HIGH); | |
| digitalWrite(7, HIGH); | |
| Serial.begin(9600); | |
| irrecv.enableIRIn(); // Start the receiver | |
| } | |
| void loop() { | |
| if (irrecv.decode(&results)) { | |
| Serial.println(results.value, HEX); | |
| if (results.value == 0x40BD00FF) red ^= 1; | |
| if (results.value == 0x40BD807F) green ^= 1; | |
| if (results.value == 0x40BD40BF) blue ^= 1; | |
| if (results.value == 0x40BDA25D) on ^= 1; | |
| if (on) | |
| { | |
| if (red) | |
| { | |
| digitalWrite(9, LOW); | |
| } | |
| else | |
| { | |
| digitalWrite(9, HIGH); | |
| } | |
| if (green) | |
| { | |
| digitalWrite(8, LOW); | |
| } | |
| else | |
| { | |
| digitalWrite(8, HIGH); | |
| } | |
| if (blue) | |
| { | |
| digitalWrite(7, LOW); | |
| } | |
| else | |
| { | |
| digitalWrite(7, HIGH); | |
| } | |
| } | |
| else | |
| { | |
| digitalWrite(9, HIGH); | |
| digitalWrite(8, HIGH); | |
| digitalWrite(7, HIGH); | |
| } | |
| irrecv.resume(); // Receive the next value | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment