标签:
1 #include "reg52.h"
2
3 unsigned int x;//数组下标
4
5 unsigned char LED_1[]={0XFE,0XFD,0XFB,0XF7,
6 0XEF,0XDF,0XBF,0X7F,0XFF};//从1号灯->8号灯
7
8 unsigned char LED_2[]={0X7F,0XBF,0XDF,0XEF,
9 0XF7,0XFB,0XFD,0XFE,0XFF};//从8号灯->1号灯
10
11 //简单的延时器
12 void delay(unsigned int cnt)
13 {
14 while(--cnt);
15 }
16
17 void main(void)
18 {
19 //从1号灯->8号灯,每次亮1个灯
20 for(x=0;x<=8;x++)
21 {
22 P1=LED_1[x];
23 delay(35000);
24 }
25 //从8号灯->1号灯,每次亮1个灯
26 for(x=0;x<=8;x++)
27 {
28 P1=LED_2[x];
29 delay(35000);
30 }
31
32 //全部灯 亮3下 灭3下
33 for(x=0;x<3;x++)
34 {
35 delay(30000);
36 P1=0X0;//全亮
37 delay(30000);
38 P1=0XFF;//全灭
39 }
40
41 }
标签:
原文地址:http://www.cnblogs.com/jhcla/p/5794156.html