Hello, after taking so much from this forum in my ongoing learning process, I wanted to give something back. It is probably not much, but I feel like sharing.
so the following is a sketch that prints on the serial monitor a timer, in the format HH:MM:SS.
There is literally nothing more to this, but the web seemed a bit spread out on this simple subject, so I thought it could be relevant and useful anyway.
It is coarse, dumb-proof (written by one), so much that it lacks comments, it is really self-explanatory.
I am probably devouring memory with this, so any improvement is more than welcome, as it always should be.
Do not use delay.
The delay(1000) means that it wait in inaction 1s, then other commands take some time so the print hardly will be in second interval. You have already test for 1s. Utilize this.
I don't get it, sorry. This just works as a timer, I actually need the delay so that the printed timer refreshes every 1s... And I am working on it to measure cooling times of an insulated enclosure, so I wouldn't mind if the sensor readings refreshed every second as well. But this is even beyond the scope of my post...
Then just couple it with the seconds update Although your whole timer thing doesn't make any sense.
Thing is, even if the clock of the Arduino is very accurate, the delay() only delays in that single command, the rest of the code isn't taken into account an although not much, will take time to execute.
And also, the splitting of hours1 and hours2 does not make sense...
All in all, it's a complicated and flawed "simple example"
Since millis() will return some large value after 1 second, the if statement will always be executed. That's probably why you gave up and used delay() but you never went back and tried to solve this.
smntnz:
It is coarse, dumb-proof (written by one), so much that it lacks comments, it is really self-explanatory.
because I found non of the statements to be true.... :
But, we are here to learn, even I am And you're reasonable but the old dogs here have encountered sooooo many stubborn newbies which just don't want to hear what they don't like. For example, not reading the simple forum rules to keep the forum tidy, not posting all the code, making it a XY-problem, don't want to hear there plan of action is flawed etc. That does make you a little bit hard when someone makes a statement like yours above