I am trying to break millis down into its components parts regarding
conversion to seconds/minutes.
The code below works...sort of. But I thought the modulus operator
would take the remainder and and throw it back to the millis value.
I am probably misapplying the operator, right?
The issue is once the conversion passes the 1 minute mark the seconds continue to count up instead of resetting to 0.
Min Sec
0 .... 0
0..... 2
0 .... 4
0 .... 58
1 .... 60 < here it should go to 0
1 .... 62
and so on....
I see the minutes went up then down. Looks like my conditional was visited many times in one second. Need a flag to say "we did the 60s = 1m and s = 0, do not enter" until seconds change to 1.
You seem to have hit upon a winning formula!!! I am curious about the use of the curly brackets on those second / minute code lines.
What is the reason for that instead of just enclosing them parethentically?
It’s another way to initialize a variable in C++, usually more for more complex types but Brace-initialization is a uniform method for initializing data in C++ (11 and beyond). For this reason, it is also called uniform initialization
I am trying your code but think millis needs the closed parenthesis ().
I appreciate your warning about mixing integer definitions. It is a weak area of my C understanding admittedly. I am really just an old neopyhte barely holding on to grasping everything.... lol.
Without a reliance on the dreaded "c & p" I would be sunk....drowned.
Please keep in mind that the processor you are using may or my not have built in division (atmega328p does not), so / or % will be slow compared to integer - or *.