|
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar aa,fen,miao,zhong;
void delay(uint z);
void main()
{
aa=0;
zhong=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
P0=fen;
P2=0;
delay(10);
P0=miao;
P2=1;
delay(10);
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
zhong++;
if(zhong==60)
{
zhong=0;
P1=0x00;
}
fen=table[zhong/10];
miao=table[zhong%10];
}
}
|
|