xxxxxxxxxx
// Save the current button state for comparison in the next loop
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Pin for the button
const int buttonPin = 7;
// Counter variable
int counter = 0;
// Variable to store the button state
int buttonState = 0;
int lastButtonState = 0;
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print the initial counter value
lcd.print("Counter: 0");
// Set the button pin as input
pinMode(buttonPin, INPUT);