#include <TM1637Display.h>
#define CLK 12
#define DIO 11
TM1637Display display(CLK, DIO);
long tiempoinicio = 0;
long tiempo = 0;
long tiempofin = 0;
#define TIEMPOMAX 90000
int contador = 0;
int inicio = 0;
#define BOTONINICIO 2
#define BOTONRESET 4
void setup() {
display.setBrightness(7, true);
display.clear();
pinMode(BOTONINICIO, INPUT_PULLUP);
pinMode(BOTONRESET, INPUT_PULLUP);
}
void loop() {
while (inicio == 0) {
if (digitalRead(BOTONRESET) == 0) {
display.setBrightness(7, true);
display.clear();
tiempoinicio = 0;
tiempo = 0;
tiempofin = 0;
contador = 0;
delay(250);
}
if (digitalRead(BOTONINICIO) == 0) {
delay(100);
display.setBrightness(7, true);
display.clear();
inicio = 1;
tiempo = 0;
contador = 0;
tiempoinicio = millis();
tiempofin = (tiempoinicio + TIEMPOMAX);
break;
}
}
while (inicio == 1) {
tiempo = millis();
if (tiempo <= tiempofin) {
contador = ((tiempo - tiempoinicio) / 10);
display.showNumberDecEx(contador, 0x40, true, 4, 0);
}
if (digitalRead(BOTONINICIO) == 0 || tiempo > tiempofin) {
inicio = 0;
delay(250);
break;
}
}
}