#include <LiquidCrystal.h>
// Initialize the LCD with the numbers of the interface pins
LiquidCrystal lcd(2, 11, 12, 7, 6, 5);
const int buttonPin = 13;
int chickenTenderCounter = 0;
// Initialize previous button state variable
int prevButtonState = HIGH;
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Chicken Tender:");
// Initialize button pin
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// Read the state of the button
int buttonState = digitalRead(buttonPin);
// Check if the button is pressed and the previous state was not pressed
if (buttonState == LOW && prevButtonState == HIGH) {
// Increment the counter
chickenTenderCounter++;
// Update the LCD display
lcd.setCursor(0, 1);
lcd.print(chickenTenderCounter);
// Delay to avoid multiple counts from a single button press
delay(250);
}
// Update the previous button state
prevButtonState = buttonState;
}