滚动显示0~7
源代码
1 #include
2 #define uchar unsigned char
3 #define uint unsigned int
4 uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0xff};//数字0~F的编码表。本程序只用了0~7
5 uchar code tab[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//从左到右位置的地址变。1~8对应管脚高电平有效。本程序用位左移操作更佳。
6 void delay(uint z)
7 {
8 uint x,y;
9 for(x=z;x>0;x--)
10 for(y=110;y>0;y--);
11 }
12 void main()
13 {
14 uint i;
15 while(1)
16 {
17 for(i=0;j<8;i++)
18 {
19 P0=table[i];
20 P2=tab[i];
21 delay(500);
22
23 }
24 }
25 }
相关文章









