#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Create LCD object (address, columns, rows)
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change 0x27 to 0x3F if your LCD doesn't work
const int ledPin = 8;
bool ledState = true; // LED initially ON
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, ledState); // Turn LED ON
lcd.begin(16, 2); // ✅ Fix: Specify columns and rows
lcd.backlight(); // Turn on backlight
lcd.setCursor(0, 0);
lcd.print("LED Status:");
updateDisplay();
}
void loop() {
// Static display; you can later add button control here
}
void updateDisplay() {
lcd.setCursor(0, 1);
if (digitalRead(ledPin) == HIGH) {
lcd.print(" ON ");
} else {
lcd.print(" OFF ");
}
}