#include <IRremote.hpp>
#define IR_RECEIVE_PIN 7
struct Command {
IRRawDataType code; // numeric IR code
const char* command; // command name
};
Command commandList[] = {
{0x5DA2FF00, "power"},
{0x1DE2FF00, "menu"},
{0xDD22FF00, "test"},
{0xFD02FF00, "plus"},
{0x3DC2FF00, "undo"},
{0x3DC2FF00, "channel back"},
{0x57A8FF00, "play"},
{0x6F90FF00, "next channel"},
{0x9768FF00, "zero"},
{0x6798FF00, "minus"},
{0x4FB0FF00, "1 step back"},
{0xCF30FF00, "one"},
{0xE718FF00, "two"},
{0x857AFF00, "three"},
{0xEF10FF00, "four"},
{0xC738FF00, "five"},
{0xA55AFF00, "six"},
{0xBD42FF00, "seven"},
{0xB54AFF00, "eight"},
{0xAD52FF00, "nine"}
};
const int commandCount = sizeof(commandList) / sizeof(commandList[0]);
void setup() {
Serial.begin(115200);
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}
void loop() {
if (IrReceiver.decode()) {
IRRawDataType outcome = IrReceiver.decodedIRData.decodedRawData;
// Look up in table
const char* cmd = "unknown";
for (int i = 0; i < commandCount; i++) {
if ( outcome == commandList[i].code) {
cmd = commandList[i].command;
break;
}
}
Serial.println(cmd);
IrReceiver.resume();
}
}