|
程序由徐虎编写。
三位999 计数器,
- //圣源电子制作:www.syyyd.com
- //程序:徐虎 编写!
- #include<reg52.h>
- #include<absacc.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit key=P3^7;
- sbit rest=P3^6;
- uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- void delay10ms(void)
- {
- unsigned char a,b,c;
- for(c=1;c>0;c--)
- for(b=38;b>0;b--)
- for(a=130;a>0;a--);
- }
- void main (void)
- {
- uint Count=0;
- P0=0x3f;
- P1=0x3f;
- P2=0x3f;
- while(1)
- {
- if(rest==0)
- {
- delay10ms();
- if(rest==0)
- while(rest==0)
- {
- Count=0;
- P0=table[Count/100];
- P1=table[(Count%100)/10];
- P2=table[Count%10];
- }
- }
- if(key==0)
- {
- delay10ms();
- if(key==0)
- {
- while(key==0);
- {
- Count++;
- if(Count==1000)
- Count=0;
- P0=table[Count/100];
- P1=table[(Count%100)/10];
- P2=table[Count%10];
- }
- }
- }
- }
- }
复制代码
程序.zip
(4 KB, 下载次数: 69)
|
|