
LCD display build:
http://www.instructables.com/id/How-to-use-an-LCD-displays-Arduino-Tutorial/
Adding Button:
https://www.arduino.cc/en/tutorial/button
Code (include liquid crystal library as well – did not add here since youtube doesnt allow angle brackets):
int previous_state = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int counter = 0;
const int buttonPin = 8;
int buttonState = 0;
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“Button pressing”);
pinMode(buttonPin, INPUT);
previous_state = LOW;
}
void loop() {
buttonState = digitalRead(buttonPin);
lcd.setCursor(0,1);
if(buttonState == HIGH && previous_state == LOW){
counter++;
previous_state = HIGH;
}
else if(buttonState == LOW){
previous_state = LOW;
}
lcd.print(counter);
}
source