i'm writing function counts down 3 on microprocessor , lcd screen.
void countdown() { _delay_ms(1000); draw_string("3",40,20); _delay_ms(1000); clear(); draw_string("2",40,20); _delay_ms(1000); clear(); draw_string("1",40,20); _delay_ms(1000); clear(); }
i tried it's inefficient , bad practice.
how write correctly?
use for
loop:
for (char c = '3'; c > '0'; c--) { // convert c ascii value , null-terminate char str[2] = { c, '\0' }; // draw string draw_string(str, 40, 20); _delay_ms(1000); clear(); }
Comments
Post a Comment