- #include <reg52.h>
- typedef unsigned char u8;
- typedef unsigned int u16;
- sbit LSA=P2^2;
- sbit LSB=P2^3;
- sbit LSC=P2^4;
- u16 code smgduan[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f};
- void delay(u16 i)
- {
- while(i--);
- }
- void main()
- {
- int a,b,c;
- b=1;
- while(1)
- {
-
- if(a==10)
- {
-
- b++;
- }
-
- if(b==10)
- {
-
- c++;
- }
-
- for(a=0;a<10;a++)
- {
- LSA=0;
- LSB=0;
- LSC=0;
- P0=smgduan[a];
- delay(50000);
- }
- if(a==10)
- {
- LSA=1;
- LSB=0;
- LSC=0;
- P0=smgduan[b];
- delay(50000);
- }
- if(b==10)
- {
- b=0;
- LSA=0;
- LSB=1;
- LSC=0;
- P0=smgduan[c];
- delay(50000);
- }
- }
- }
复制代码 |