#include <REGX51.H>
#include <INTRINS.H>
#define LED_NUM 8
unsigned char led_states[] = {0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F};
unsigned char cur_index = 0;
void delay(unsigned int ms) {
unsigned int i, j;
for(i=0; i<ms; i++) {
for(j=0; j<123; j++);
}
}
void main() {
while(1) {
P0 = led_states[cur_index]; // 设置当前LED
delay(500);
cur_index++; //下一个
if(cur_index == LED_NUM) {
cur_index = 0;
}
}
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交