我正在写一个函数,从3在微处理器和液晶屏幕上计数。
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();
}我试过了,但这显然是低效和糟糕的做法。
我怎么才能把这个写得正确?
发布于 2015-05-08 08:32:14
使用for循环:
for (char c = '3'; c > '0'; c--)
{
// Convert c to an ascii value and null-terminate
char str[2] = { c, '\0' };
// Draw the string
draw_string(str, 40, 20);
_delay_ms(1000);
clear();
}https://stackoverflow.com/questions/30119233
复制相似问题