sprintf .... why it does not work?
hello,
i'm trying this:
i see on serial monitor:
i'm trying this:
code: [select]
char buffer[50];
unsigned long tempo = 0;
.....
void loop(void) {
.......
tempo = millis();
sprintf( buffer , "%01d:%02d.%02d", tempo / 60000 , tempo / 1000 % 60, tempo % 1000 / 10 );
serial.println(buffer);
.....
}
i see on serial monitor:
quote
for exampleinstead should see this:
2:00.23
2 minute , correct
:
00 zero, not correct
.
23 second, position not correct, must before dot
quote
m:ss.mswhy? can me?
%01d = m 1 char minute zero
:
%02d = ss 2 char second zero
.
%02d = ms 2 char millisecond zero
%d expects int parameter, need %ld long.
Arduino Forum > Using Arduino > Programming Questions > sprintf .... why it does not work?
arduino
Comments
Post a Comment