單片機循環(huán)流水燈2
程序代碼如下:
// program name: project5.c
// 功能: 采用循環(huán)結(jié)構(gòu)實現(xiàn)流水燈的控制
#include
void delay (unsigned char i) {
unsigned char j, k;
for (k=0; k
for (j=0; j<255; j++);
}
void main () {
unsigned char i, w;
while (1) {
w=0x01;
for (i=0; i<8; i++) {
P1=~w;
delay(200);
w<<=1;
}
}
}
關(guān)鍵詞:
單片機循環(huán)流水
評論