C51学习 之 LED流水灯

电路图

 代码

 1 #include <reg52.h>
 2 
 3 void delay(unsigned int value)
 4 {
 5     while(value--);
 6 }
 7 int main()
 8 {
 9     P1 = 0xfe;
10     while(1) {
11         P1 = ~(~P1 << 1);
12         delay(100000);
13         if (P1 == 0xff) {
14             P1 = 0xfe;
15         }
16      }
17     return 0;
18 }
原文地址:https://www.cnblogs.com/wangfeicom/p/14827148.html