#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long int
uchar aa;
long int temp;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f};
void display(long int i);
void delay(uint z);
void init();
void main()
{
init();
while(1)
{
if(TF0==1)
{
TF0=0;
TH0=0x4c;
TL0=0x00;
aa++;
}
if(aa==1)
{
aa=0;
temp++;
}
if(temp==86400)
temp=0;
display(temp);
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=80;y>0;y--);
}
void display(long int i)
{
long int shi1,shi0,fen1,fen0,miao1,miao0;
shi1=i/3600/10;
shi0=i/3600-(shi1*10);
fen1=i%3600/60/10;
fen0=i%3600/60-(fen1*10);
miao1=i%3600%60/10;
miao0=i%3600%60-(miao1*10);
dula=1;
P0=table[shi1];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;
wela=0;
delay(3);
dula=1;
P0=table[shi0];
dula=0;
P0=0xff;
wela=1;
P0=0xfd;
wela=0;
delay(3);
dula=1;
P0=0x40;
dula=0;
P0=0xff;
wela=1;
P0=0xfb;
wela=0;
delay(3);
dula=1;
P0=table[fen1];
dula=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delay(3);
dula=1;
P0=table[fen0];
dula=0;
P0=0xff;
wela=1;
P0=0xef;
wela=0;
delay(3);
dula=1;
P0=0x40;
dula=0;
P0=0xff;
wela=1;
P0=0xdf;
wela=0;
delay(3);
dula=1;
P0=table[miao1];
dula=0;
P0=0xff;
wela=1;
P0=0xbf;
wela=0;
delay(3);
dula=1;
P0=table[miao0];
dula=0;
P0=0xff;
wela=1;
P0=0x7f;
wela=0;
delay(1);
}
void init()
{
TMOD=0x01;
TH0=0x4c;
TL0=0x00;
TR0=1;
temp=65520;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我是在开发板上写的程序
但我改了秒的delay值,好像没什么改变呀!
一周热门 更多>