Created
October 16, 2019 20:08
-
-
Save theresajayne/9aa5a4ed059374f847b51a476a110714 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> | |
#include <IRremoteInt.h> | |
int IRPIN = 2; | |
int ledPin = 13; | |
IRrecv irrecv(IRPIN); | |
bool active = false; | |
decode_results result; | |
void setup() { | |
pinMode(ledPin, OUTPUT); | |
Serial.begin(9600); | |
Serial.println("Enabling IRin"); | |
irrecv.enableIRIn(); | |
Serial.println("Enabled IRin"); | |
} | |
void loop() { | |
if(irrecv.decode(&result)) | |
{ | |
Serial.println(result.value,HEX); | |
if(result.value==0xFFA857) | |
{ | |
digitalWrite(ledPin, HIGH); | |
active = true; | |
} | |
if(result.value == 0xFFE01F) | |
{ | |
active = true; | |
digitalWrite(ledPin, HIGH); | |
} | |
if(result.value == 0xFFFFFFFF && active) | |
{ | |
digitalWrite(ledPin, HIGH); | |
} | |
irrecv.resume(); | |
} | |
else | |
{ | |
active = false; | |
digitalWrite(ledPin, LOW); | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment