Skip to content

Instantly share code, notes, and snippets.

@gigafide
Created October 29, 2018 14:51
Show Gist options
  • Save gigafide/9108198a5543e6fe0b086e6b583d94bd to your computer and use it in GitHub Desktop.
Save gigafide/9108198a5543e6fe0b086e6b583d94bd to your computer and use it in GitHub Desktop.
Reads IR code signals from a remote control
#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment