The timer dont work at all, there is the circuit and the code /, someone please test and help me its for today.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,4,5,6,7);
int botao1 = 8;
int botao2 = 9;
int estadoBotao1 = 0;
int estadoBotao2 = 0;
int sec, min, hora, zero;
void cronometro();
void pausa();
void setup(){
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Cronometro do");
delay(200);
lcd.setCursor(1,1);
lcd.print("Ian Rapini ._.");
delay(800);
lcd.clear();
pinMode(botao1, INPUT_PULLUP);
pinMode(botao2, INPUT_PULLUP);
sec = 0;
min = 0;
hora = 0;
zero = 0;
delay(300);
}
void loop(){
pausa();
cronometro();
}
void cronometro(){
if(!digitalRead(botao2)){
sec = 0;
min = 0;
hora = 0;
zero = 0;
lcd.clear();
}
else{
lcd.setCursor(0,0);
lcd.print("Iniciando");
int sec = 0;
int min = 0;
int hora = 0;
int zero = 0;
lcd.clear();
lcd.home();
if(millis() - zero > 1)
{
sec++;
zero = millis();
}
if(sec > 59)
{
lcd.setCursor(10, 1);
lcd.print(" ");
sec = 0;
min++;
}
if(min > 59)
{
lcd.setCursor(5, 1);
lcd.print(" ");
min = 0;
hora++;
}
if(hora == 24){
hora = 0;
}
lcd.setCursor(2, 0);
lcd.print(hora);
lcd.setCursor(4, 0);
lcd.print("h");
lcd.setCursor(0, 1);
lcd.print(min);
lcd.setCursor(2, 1);
lcd.print("m");
lcd.setCursor(5, 1);
lcd.print(sec);
lcd.setCursor(7, 1);
lcd.print("s");
}
}
void pausa()
{
static int trava = 0, pausa = 0;
{
if(!digitalRead(botao1) && !trava)
{
trava = 1;
pausa = !pausa;
}
if(digitalRead(botao1))
{
trava = 0;
}
}
while(pausa);
}