#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD(0x27,16,2);
int button = 13;
int buttonstate = 0;
int laststate = 0;
int time = 0;
int count = 0;
void setup() {
LCD.init();
LCD.backlight();
Serial.begin(9600);
pinMode(button, INPUT);
}
void loop() {
LCD.setCursor(0,1);
buttonstate = digitalRead(button);
if(buttonstate==HIGH && laststate == LOW ){
for(int i=0; i<30; ++i){
++count;
LCD.println(count);
}
}
else if (buttonstate == LOW && laststate == HIGH){
laststate == LOW;
}
if (count == 1){
Serial.println("Time: ");
time = micros();
Serial.print(time);
if(time == 300000){
LCD.println(count);
LCD.setCursor(4,1);
LCD.print("vm:");
LCD.setCursor(8,1);
int vm = 30 - count;
LCD.print(vm);
}
}
if (count == 30){
LCD.println(count);
LCD.setCursor(4,1);
LCD.print("vm:0");
}
}