Arduino Timer

Hi all,

I am building a timer using Arduino. I am successfully in buiding one. But the problem is with the format it displays on LCD.

for example: it displays the time like this " 1 :1 :1"
But i wanted in this format " 01:01:01:"

Can anybody help me how to get this format?

bhanukishan:
Hi all,

I am building a timer using Arduino. I am successfully in buiding one. But the problem is with the format it displays on LCD.

for example: it displays the time like this " 1 :1 :1"
But i wanted in this format " 01:01:01:"

Can anybody help me how to get this format?

hmm, all I can think of is maybe formatting it urself instead of using only integers.

like you probably have every second minute and hour set to an integer or something.

you could have 2 integers one for seconds and one for every ten seconds like this

[0] [1]:[0] [1]:[0] [1]

each of those being a variable

but yeah thats just an idea :slight_smile:

if(hour<10) LCD.print('0');
LCD.print(hour);

Minutes and seconds will look similar.

char s[10];

sprintf(s, "%02d:%02d:%02d", hours, minutes, seconds);
lcd.print(s);

Regards,
Ray L.

Thank you all