本帖最后由 ty1649 于 2013-8-13 10:20 编辑
#include <reg51.h>
#define uchar unsigned char
uchar duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar wei[]={0x01,0x02,0x04,0x08,0x10,0x20};
uchar zhong[]={0,0,0,0,0,0};
uchar i,second,minite,hour;
int t;
void main()
{
TMOD=0x00;
TH0=(8192-250)/256;
TL0=(8192-250)%256;
EA=1;ET0=1;TR0=1;
while(1);
}
void
timer() interrupt 1
{
TH0=(8192-250)/256;
TL0=(8192-250)%256;
P0=duan【zhong【i】】
;
P2=wei【i】;
i++;
if(i==6)
i=0;
if(t++==4000)
{
t=0;
second++;
if(second==60)
{
second=0;
minite++;
if(minite==60)
{
minite=0;
hour++;
if(hour==24)
{
hour=0;
}
}
}
zhong[0]=second%10;
zhong[1]=second/10;
zhong[2]=minite%10;
zhong[3]=minite/10;
zhong[4]=hour%10;
zhong[5]=hour/10;
}
}
-
-
-
一周热门 更多>