#include <LiquidCrystal.h>
LiquidCrystal lcd(9, 10, 5, 4, 3, 2);
const int startButton = 11;
const int stopButton = 12;
unsigned long startTime = 0;
float elapsedTime = 0.0;
bool running = false;
void setup() {
lcd.begin(16, 2);
pinMode(startButton, INPUT_PULLUP);
pinMode(stopButton, INPUT_PULLUP);
lcd.print("Time: 0.00s");
}
void loop() {
if (!running) {
if (digitalRead(startButton) == LOW) {
startTime = millis();
running = true;
}
} else {
unsigned long currentTime = millis();
elapsedTime = (currentTime - startTime) / 1000.0;
lcd.setCursor(0, 0);
lcd.print("Time: ");
lcd.print(elapsedTime, 2);
lcd.print("s ");
if (digitalRead(stopButton) == LOW) {
running = false;
}
}
}