Dear,
I'm having a litle problem figuring out how to get my countdown time that i'm using to display 2 digits for ever hour , minute and second .
For example :
Timer : 1:30:9 -> Meaning 1 hour , 30 minutes and 9 seconds
and i whould like to get it displayed as :
Timer : 01:30:09
Does some one have the solution for this ?
He would be my here ^^ .
Here is the main code i'm using :
void countdown(){
static unsigned long lastTick = 0; // set up a local variable to hold the last time we decremented one second
// decrement one second every 1000 milliseconds
if (second > 0) {
if (millis() - lastTick >= 1000) {
lastTick = millis();
second--;
}
}
// decrement one minute every 60 seconds
if (minute > 0) {
if (second <= 0) {
minute--;
second = 60; // reset seconds to 60
}
}
// decrement one hour every 60 minutes
if (hour > 0) {
if (minute <= 0) {
hour--;
minute = 60; // reset minutes to 60
}//closes if
}//closes if
moveCursor("02", "01");
Serial.print("Time: ");
Serial.print(hour, DEC); // the hour, sent to the screen in decimal format
Serial.print(":"); // a colon between the hour and the minute
Serial.print(minute, DEC); // the minute, sent to the screen in decimal format
Serial.print(":"); // a colon between the minute and the second
Serial.print(second, DEC); // the second, sent to the screen in decimal format
Serial.print(" ");
} //close countdown();
Hope some one can help me !
Thanks in advance
Jochem