本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar count;
uint disnum;
sbit dula=P2^6;
sbit wela=P2^7;
sbit key1=P3^4;
uchar code tableshige[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,
0x7d,0x07,0x7f,0x6f,0x77};
uchar code tablebai[]={
0xbf,0x86,0xdb,0xcf,0xe6,0xed,
0xfd,0x87,0xff,0xef,0xf7};
void display(uchar,uchar,uchar);
void delay(uchar);
void main()
{
EA=1;
ET1=1;
TMOD=0x10;
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
TR1=1;
while(1)
{
if(count==1)
{
count=0;
if(disnum==1000)
disnum=0;
disnum++;
if(key1==0)
{
delay(5);
if(key1==0)
TR1=0;
while(!key1);
display(disnum/100,disnum%100/10,disnum%10);
delay(5);
while(!key1);
TR1=1;
}
}
display(disnum/100,disnum%100/10,disnum%10);
}
}
void time1() interrupt 3
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
count++;
}
void display(uchar bai,uchar shi, uchar ge)
{
P0=0xff;
wela=1;
wela=0;
P0=tablebai[bai];
dula=1;
dula=0;
P0=0xfe;
wela=1;
wela=0;
delay(1);
P0=0xff;
wela=1;
wela=0;
P0=tableshige[shi];
dula=1;
dula=0;
P0=0xfd;
wela=1;
wela=0;
delay(1);
P0=0xff;
wela=1;
wela=0;
P0=tableshige[ge];
dula=1;
dula=0;
P0=0xfb;
wela=1;
wela=0;
delay(1);
}
void delay(uchar x)
{
uchar a,b;
for(a=x;a>0;a--)
for(b=100;b>0;b--);
} |