#include <Streaming.h>
Print& cout {Serial};
#define DECODE_NEC
#define IR_RECEIVE_PIN 5 // (Default is 2)
// #define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
// #define DEBUG // Activate this for lots of lovely debug output from the decoders.
// #define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#define RAW_BUFFER_LENGTH 100 // #define RAW_BUFFER_LENGTH 112 // MagiQuest requires 112 bytes.
#define NO_LED_FEEDBACK_CODE // Saves 566 bytes program memory
#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program space.
#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 650 bytes program space if all other protocols are active
#include <IRremote.hpp>
void setup() {
Serial.begin(115200);
delay(1000);
cout << F("START ") << __FILE__ << F(" from ") << __DATE__ << F("\r\nUsing library version ") << VERSION_IRREMOTE
<< endl;
cout << F("Enabling IRin...") << endl;
IrReceiver.begin(IR_RECEIVE_PIN);
cout << F("Ready to receive IR signals of protocols: ");
printActiveIRProtocols(&Serial);
cout << F("at pin ") << IR_RECEIVE_PIN << endl;
}
void loop() {
if (IrReceiver.decode()) {
switch (IrReceiver.decodedIRData.command) {
case 0x68: cout << ("0 "); break;
case 0x30: cout << ("1 "); break;
case 0x18: cout << ("2 "); break;
case 0x7A: cout << ("3 "); break;
case 0x10: cout << ("4 "); break;
case 0x38: cout << ("5 "); break;
case 0x5A: cout << ("6 "); break;
case 0x42: cout << ("7 "); break;
case 0x4A: cout << ("8 "); break;
case 0x52: cout << ("9 "); break;
case 0xE2: cout << ("Menu\n"); break;
case 0xC2: cout << ("Back\n"); break;
case 0x22: cout << ("Test\n"); break;
case 0x02: cout << ("+\n"); break;
case 0xA8: cout << ("Play\n"); break;
case 0x98: cout << ("-\n"); break;
case 0xB0: cout << ("C\n"); break;
case 0xE0: cout << ("Rewind\n"); break;
case 0x90: cout << ("Forward\n"); break;
case 0xA2: cout << ("On/Off\n"); break;
default:
IrReceiver.printIRResultShort(&Serial);
// IrReceiver.printIRResultRawFormatted(&Serial);
break;
}
delay(65);
IrReceiver.resume(); // Receive the next value
}
}