- #include<reg52.h>
- #define uint unsigned int
- sbit dula=P2^0;
- sbit wela=P2^1;
- uint i;
- unsigned code table[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
- void delay(uint ms)
- {
- uint ti;
- while(ms--)
- {
- for(ti=0;ti<82;ti++){}
- }
- }
- void main()
- {
- while(1)
- {
- P1=0xff; //1111 1111
- for(i=0;i<=8;i++)
- {
- P0=table[i];
- dula=1;
- dula=0;
- P0=0xfe; //1111 1110
- wela=1;
- wela=0;
- delay(1000);
- P1=P1<<1;
- }
-
- }
- }
复制代码 |