Created
February 2, 2017 18:03
-
-
Save AiHiro/f677975b35f4f6656db0cb4752eca8e7 to your computer and use it in GitHub Desktop.
This file contains 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 input_pin = 10; //set D10 as input signal pin | |
const int GLED = 11; | |
const int YLED = 9; | |
const int RLED = 8; | |
IRrecv irrecv(input_pin); | |
decode_results signals; | |
int test = 0; | |
const long one = 16724175; | |
const long two = 16718055; | |
const long three = 16743045; | |
void setup() | |
{ | |
Serial.begin(9600); | |
irrecv.enableIRIn(); // enable input from IR receiver | |
pinMode(GLED,OUTPUT); | |
pinMode(YLED,OUTPUT); | |
pinMode(RLED,OUTPUT); | |
} | |
void loop() { | |
if (irrecv.decode(&signals)) { | |
Serial.println(signals.value,HEX); | |
test = signals.value; | |
switch(test) { | |
case one: | |
digitalWrite(GLED,HIGH); | |
digitalWrite(YLED,LOW); | |
digitalWrite(RLED,LOW); | |
break; | |
case two: | |
digitalWrite(GLED,LOW); | |
digitalWrite(YLED,HIGH); | |
digitalWrite(RLED,LOW); | |
break; | |
case three: | |
digitalWrite(GLED,HIGH); | |
digitalWrite(YLED,LOW); | |
digitalWrite(RLED,HIGH); | |
break; | |
default: | |
digitalWrite(GLED,LOW); | |
digitalWrite(YLED,LOW); | |
digitalWrite(RLED,LOW); | |
break; | |
} | |
irrecv.resume(); // get the next signal | |
} | |
//digitalWrite(GLED,HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment