You can also use www.tinkercad.com to simulate.
There are a multitude of issues with your code. Here are a few:
-
You shouldn't name a variable the same as a function name. Also, if pausa ever becomes true you will be stuck right here until you reset:
while(pausa); -
zero needs to be an unsigned long
-
You have sec, min, hora, and zero redefined as locals in the cronometro() function. This causes sec, min, hora to never increment.
-
There is no reason to call the following every time in cronometro() function. It causes the LCD to blink:
lcd.setCursor(0,0);
lcd.print("Iniciando");
lcd.clear();
lcd.home();
- There is no reason to update the LCD unless seconds increases or a button is pushed. It is a waste of time.