const int buttonPin = 2;
int time = 0;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600); //порт
}
void loop() {
if (digitalRead(buttonPin) == LOW) {
time = 0;
Serial.println("Таймер обнулён");
delay(300);
} else {
time++;
Serial.print("Прошедшее время: ");
Serial.print(time);
Serial.println(" секунд");
delay(1000);
}
}