// include the library code:
#include <LiquidCrystal.h>
// initialize the LCD interface pins
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// initialize button
const int button = 8;
unsigned long resetTime = 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("hello, world!");
pinMode(button, INPUT);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
if (digitalRead(button) == HIGH){
resetTime = millis();
lcd.print(" ");
lcd.setCursor(0,1);
}
unsigned long time = millis() - resetTime;
lcd.print(time / 1000);
}