Ok, I need some help

Hi! :slight_smile:
Im building a timer on my arduino. Im using an lcd (16, 2). I have an hour counter, a minute counter and a seconds counter on one screen, counting at the same time. But there is one problem: when the seconds, or minutes counter reaches 60, the minute or hour is count, but the minutes and seconds continue to count. I dont know how to reset the counter when it reaches 60. Please answer, I need help!
Here is my code (a bit messy and very dumb, Im a begginer):

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8 );

void setup()
lcd.begin(16, 2);
void loop()
lcd.print(millis() / 3600000);
lcd.setCursor(0, 1);
lcd.setCursor(4, 0);
lcd.print(millis() / 60000);
lcd.setCursor(4, 1);
lcd.setCursor(8, 0);
lcd.print(millis() / 1000);
lcd.setCursor(8, 1);

Now I just need to add or change something. Ok, Im waiting for your help!
Until further notice.

Use the modulo operator - no need to reset the minute/second counters, just do like (millis()/1000)%60 and you get the seconds value you want.


Use the 'modulo' operator '%' to cause the minutes and seconds to count 0 to 59 over and over.

ย   lcd.print((millis() / 60000) % 60);
ย  lcd.print((millis() / 1000) % 60);

Omg, thanks alot. Such a fast answer!