#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int ledPin = 8; // Pin where LED is connected
const int buttonPin = 7; // Pin where button is connected
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
lcd.begin(16, 2); // Set up the LCD's number of columns and rows
lcd.print("LED Status:"); // Print initial text to the LCD
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH);
lcd.setCursor(0, 1); // Set cursor to second line
lcd.print("ON "); // Print LED status
} else {
digitalWrite(ledPin, LOW);
lcd.setCursor(0, 1);
lcd.print("OFF"); // Print LED status
}
delay(200); // Small delay for button debounce
}