Skip to content

Instantly share code, notes, and snippets.

@AiHiro
Created February 2, 2017 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AiHiro/f677975b35f4f6656db0cb4752eca8e7 to your computer and use it in GitHub Desktop.
Save AiHiro/f677975b35f4f6656db0cb4752eca8e7 to your computer and use it in GitHub Desktop.
#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