#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <IRremote.h>
#define IR_PIN 2 // Pin connected to the IR sensor
#define LCD_COLS 16
#define LCD_ROWS 2
IRrecv irrecv(IR_PIN);
decode_results results;
LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS); // Change 0x27 to your LCD I2C address
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
lcd.begin(LCD_COLS, LCD_ROWS);
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press a button");
}
void loop() {
if (irrecv.decode(&results)) {
// Display the pressed button on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Button: ");
lcd.print(results.value, HEX);
Serial.print("Button: ");
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
delay(500); // Delay to avoid repeated button presses
}
}