Skip to content

Instantly share code, notes, and snippets.

@theresajayne
Created October 16, 2019 20:08
Show Gist options
  • Save theresajayne/9aa5a4ed059374f847b51a476a110714 to your computer and use it in GitHub Desktop.
Save theresajayne/9aa5a4ed059374f847b51a476a110714 to your computer and use it in GitHub Desktop.
#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