#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Replace 0x27 with the address of your I2C LCD module
int upButton = 10;
int downButton = 11;
int selectButton = 12;
unsigned long backlightOffTime = 0; // Variable to store the time to turn off the backlight
void setup() {
lcd.init();
lcd.setCursor(0, 0);
lcd.print("....Welcome....");
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(selectButton, INPUT_PULLUP);
}
void loop() {
// Your main code here
if (!digitalRead(downButton) || !digitalRead(upButton) || !digitalRead(selectButton)) {
lcd.backlight();
backlightOffTime = millis() + 3000; // Set the time to turn off backlight after 3 seconds
}
// Check if it's time to turn off the backlight
if (millis() >= backlightOffTime) {
lcd.noBacklight();
}
}