#include <LiquidCrystal.h>
// Initialize the LiquidCrystal library with the interface pins
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int counter = 0; // Variable to store the counter value
void setup() {
// Set up the LCD's number of columns and rows
lcd.begin(16, 2);
// Display a welcome message on the first row
lcd.setCursor(0, 0);
lcd.print("Counter Demo");
}
void loop() {
// Display the counter value on the second row
lcd.setCursor(0, 1); // Move cursor to the start of the second row
lcd.print("Count: ");
lcd.print(counter);
// Ensure the previous number is cleared by overwriting extra digits with spaces
lcd.print(" ");
// Increment the counter
counter++;
// Wait for 1 second
delay(1000);
}