Skip to content

Instantly share code, notes, and snippets.

@besi
Created February 7, 2018 21:07
Show Gist options
  • Save besi/99ab4d00b5dd538314e7fc0edec7863f to your computer and use it in GitHub Desktop.
Save besi/99ab4d00b5dd538314e7fc0edec7863f to your computer and use it in GitHub Desktop.
/*
Directly attach the IR receiver diode to the Pins:
- Left: Signal Pin 2
- Middle: GND
- Right: 5V
*/
#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
irrecv.enableIRIn();
Serial.begin(115200);
pinMode(RECV_PIN, INPUT);
}
void loop() {
if (irrecv.decode(&results)) {
int v = results.value;
if (v != 0 && v != 0x4AB0F7B6 && v != 0xFFFFF7B6) {
Serial.println(v, HEX);
}
if (v == 0x7887) {
Serial.println("Power pressed");
}
irrecv.resume();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment