/*
################################################################
|| ||
|| Title: IR Remote Test ||
|| Author: GC1CEO ||
|| Date: 4/5/2026 ||
|| ||
|| Description: ||
|| Press a button the IR remote and its translated via the IR ||
|| Receiver to the Serial Monitor. ||
|| ||
################################################################
*/
#include <IRremote.h>
const int RECV_PIN = 11; // Pin connected to IR receiver
void initializeReceiver() {
// set up the receiver to receive input the NEW way- it changed from earlier versions)
IrReceiver.begin(RECV_PIN);
}
void setup() {
Serial.begin(9600); // Start serial communication for debugging
initializeReceiver();
Serial.println("IR Receiver ready to receive signals.");
}
void loop() {
// Check if a signal has been received
if (IrReceiver.decode()) {
Serial.print("Received IR code: ");
translateIR();
IrReceiver.resume();
}
}
void translateIR() {
// Takes command based on IR code received
switch (IrReceiver.decodedIRData.command) {
case 162:
Serial.println("POWER");
break;
case 226:
Serial.println("MENU");
break;
case 34:
Serial.println("TEST");
break;
case 2:
Serial.println("PLUS");
break;
case 194:
Serial.println("BACK");
break;
case 224:
Serial.println("PREV.");
break;
case 168:
Serial.println("PLAY");
break;
case 144:
Serial.println("NEXT");
break;
case 104:
Serial.println("num: 0");
break;
case 152:
Serial.println("MINUS");
break;
case 176:
Serial.println("key: C");
break;
case 48:
Serial.println("num: 1");
break;
case 24:
Serial.println("num: 2");
break;
case 122:
Serial.println("num: 3");
break;
case 16:
Serial.println("num: 4");
break;
case 56:
Serial.println("num: 5");
break;
case 90:
Serial.println("num: 6");
break;
case 66:
Serial.println("num: 7");
break;
case 74:
Serial.println("num: 8");
break;
case 82:
Serial.println("num: 9");
break;
default:
Serial.println(IrReceiver.decodedIRData.command);
Serial.println(" other button");
}
}