#include <Wire.h> // Include the Wire library for I2C communication
#include <LiquidCrystal_I2C.h> // Include the LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2); // Replace 0x3F with the address of your I2C LCD module
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0);
}
void loop() {
// Your main code here
// To turn off the backlight
lcd.noBacklight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Backlight Off");
delay(1000); // Wait for a second with the backlight off
// To turn on the backlight
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Backlight On");
delay(1000); // Wait for a second with the backlight on
}