// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonPushCounter = -1;
int lastButtonState = 0;
void setup() {
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
pinMode(buttonPin, INPUT);
}
void loop() {
if (buttonPushCounter<=60) {
buttonState = digitalRead(buttonPin);
lcd.setCursor(0, 3);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
buttonPushCounter++;
}
delay(50);
}
lastButtonState = buttonState;
if (buttonPushCounter<10) {lcd.print (" ");}
lcd.print (buttonPushCounter);
if (buttonPushCounter>60) {buttonPushCounter=0;}
}
}