#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,t;
void main()
{
TMOD=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
EA=1;ET0=1;TR0=1;
for(;;){
}
}
void timer() interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
P0=duan[zhong
];
P2=wei;
i++;
if(i++==6){
i=0;
}
if(t++==10)
{
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;
}
此帖出自小平头技术问答
if(i++==6){
i=0;
}
if(t++==10)
这段有毛病,t没有回0
一周热门 更多>