新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)LED燈計(jì)數(shù)

單片機(jī)LED燈計(jì)數(shù)

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

代碼如下:
#include
sbit P1_7 = P1 ^ 7;
sbit P1_6 = P1 ^ 6;
sbit P1_5 = P1 ^ 5;
sbit P1_4 = P1 ^ 4;
void delay(unsigned char i) {
unsigned int j = 0,k = 0;
for(k = 0; k < i; k++)
for(j = 0; j < 255; j++);
}
void main(void) {
char i = 0;
while (1) {
P1_7 = 0;
delay(200);
P1_6 = 0;
delay(200);
P1_5 = 0;
delay(200);
P1_4 = 0;
delay(200);
P1_7 = 1;
delay(200);
P1_6 = 1;
delay(200);
P1_5 = 1;
delay(200);
P1_4 = 1;
delay(200);
}
}



關(guān)鍵詞: 單片機(jī)LED燈計(jì)

評(píng)論


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

關(guān)閉