- #include<reg51.h>
- unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
- unsigned char code table2[]={0xf7,0xfb,0xfd,0xfe};
- unsigned char i,num;
- unsigned int count;
- void delay(int);
- main()
- {
- while(1)
- {
- {if(count==9999)count=0;}
- count++;
- for(num=0;num<200;num++)
- {P0=0x00;
- P2=table2[0];
- P0=table1[((count%1000)%100)%10];
- delay(1);
- P0=0x00;
- P2=table2[1];
- P0=table1[((count%1000)%100)/10];
- delay(1);
- P0=0x00;
- P2=table2[2];
- P0=table1[(count%1000)/100];
- delay(1);
- P0=0x00;
- P2=table2[3];
- P0=table1[count/1000];
- delay(1);
- }
- }
- }
- void delay(int x)
- {
- int i,j;
- for(i=0;i<x;i++)
- for(j=1;j<=150;j++);
- }
复制代码
1-9999计数器.zip
(66.42 KB, 下载次数: 19)
|