熱門: 51單片機(jī) | 24小時(shí)必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂(lè)園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
3745| 15
|
請(qǐng)教師傅們一個(gè)時(shí)間推遲的51單片機(jī)程序 |
500黑幣
最佳答案你這應(yīng)該修改一下,照你這么寫,樓主得一直按著按鍵,直到2秒后事件執(zhí)行。上面的延時(shí)短點(diǎn),用于消抖,在執(zhí)行事件前面加個(gè)延時(shí)2000毫秒才是樓主想要的
直接在你這上改了
#include
#include
sbit button = P1^0; // Define button as sbit type, connected to P1.0
void delay_ms(unsigned int time)
{
unsigned int i, j;
for (i = 0; i < time; i++)
for (j = 0; j < 110; j++);
}
void mai ...
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
評(píng)分
| ||||||||
| ||
| ||
Powered by 單片機(jī)教程網(wǎng)