新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機(jī)中斷實驗1

單片機(jī)中斷實驗1

作者: 時間:2016-11-21 來源:網(wǎng)絡(luò) 收藏
電路圖:

功能:按鍵開關(guān)燈。
代碼如下:
#include
#include
sbit p1_0 = P1^0;
void delay (void) {
int a = 500;
while(a--) _nop_();
}
void LED_01() interrupt 0 using 1 {
delay();
if (INT0 == 0) {
p1_0 = !p1_0;
while (INT0 == 0);
}
}
void main () {
p1_0 = 0;
EA = 1;
EX0 = 1;
while(1);
}



關(guān)鍵詞: 單片機(jī)中斷實

評論


技術(shù)專區(qū)

關(guān)閉