Printing leading zero in LCD widget

Hi
I’m using an LCD widget to display DD:HH:MM for an uptime counter, but when the respective variables are zero, nothing displays in the display. I want to get 00:00:01, but am getting : : 1

How can I force a zero character in front of the digit being displayed?

Thanks in advance

I’d use the sprintf command to assemble your date string in the format you want before sending it to the LCD widget.

I find the documentation for this command a bit mind numbing, so it’s probably best to just google examples of DD:HH:MM formatting using sprintf.

Pete.

1 Like

Hi Pete, Thanks for that advice. I’ve not used sprintf function before so will look into it. I did manage to resolve the problem by creating a char array and populating it with the char of the number generated by the timer then pointing the lcd.print to the array. Works well, resolving the leading 0 for single digit numbers and the alignment requirements in one.