稍后上传运行视频
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
sbit dula=P2^7; //十进制数显式
sbit wela=P2^6;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x00};
void print();
void dely(uint i);
uchar aa,t,f,m,ss,sf,sm,szs,temp,key,tzw,xzw,p,zs;
ulong k;
void chu();
void jc();
void sz();
void main()
{
chu();
ss=0;
sf=0;
sm=0;
t=0;
xzw=0;
p=0;
szs=0;
while(1)
{
sz();
if(szs==1)
{
jc();
if(xzw==0)
{
k=sf*100+sm;
}
else
{
k=ss*10000+sm;
}
}
else
{
if (t==1)
{
sm=sm+1;
if(sm>=60)
{
sf=sf+1;
sm=0;
if(sf>=60)
{
ss=ss+1;
sf=0;
if(ss>=24)
{
ss=0;
}
}
}
t=0;
}
k=ss*10000+sf*100+sm;
}
print();
}
}
void dely(uint i)
{
ulong g,h;
for(g=i;g>0;g--)
for(h=5;h>1;h--);
}
void print()
{
aa=0x7f;
for(m=6;m>=1;m--)
{
f=k%10;
P0=aa;
dula=1;
dula=0;
P0=table[f];
wela=1;
wela=0;
P0=0;
dely(5);
P0=0x00;
wela=1;
wela=0;
aa=_cror_(aa,1);
if(aa==0xdf)
{
aa=_cror_(aa,1);
}
if(aa==0xfb)
{
aa=_cror_(aa,1);
}
k=k/10;
}
}
void chu()
{
TMOD=0X01;
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
EA=1;
ET0=1;
TR0=1;
}
void T0_
time() interrupt 1
{
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
t=t+1;
}
void jc()
{
P3=0xf7;
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
dely(5);
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
temp=P3;
switch(temp)
{
case 0xe7:
if(xzw==0)
{
sf=sf-1;
if(sf==0){sf=60;}
}
else
{
ss=ss-1;
if(ss==0){ss=60;}
}
break ;
case 0xd7:
if(xzw==0)
{
sf=sf+1;
if(sf==60){sf=0;}
}
else
{
ss=ss+1;
if(sf==60){sf=0;}
}
break;
case 0xb7:
xzw++;
if(xzw==2){xzw=0;}
break;
}
}
}
while(temp!=0xf7)
{
temp=P3;
temp=temp&0xf7;
}
}
void sz()
{
P3=0xfd;
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
dely(5);
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
temp=P3;
if(temp==0x7d)
{
zs=zs+1;
if(zs==1)
{
szs=1;
EA=0;
ET0=0;
}
if(zs==2)
{
szs=2;
chu();
zs=0;
}
}
}
}
while(temp!=0xfd)
{
temp=P3;
temp=temp&0xfd;
}
}
一周热门 更多>