#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar a,b,c;
void delay1ms(uint i)
{uchar j;
while(i--)
{ for(j=0;j<114;j++)
{;}
}
}
void display(uchar x,uchar y,uchar z)
{
P2=0XFE;
P0=tab[x/10];
delay1ms(1);
P2=0Xfd;
P0=tab[x%10];
delay1ms(1);
P2=0xfb;
P0=0xbf;
delay1ms(1);
P2=0XF7;
P0=tab[y/10];
delay1ms(1);
P2=0Xef;
P0=tab[y%10];
delay1ms(1);
P2=0XDF;
P0=0xbf;
delay1ms(1);
P2=0XbF;
P0=tab[z/10];
delay1ms(1);
P2=0X7F;
P0=tab[z%10];
delay1ms(1);
}
void main(void)
{EA=1;
TMOD=0X66;
ET0=1;
IT0=1;
IE0=1;
TR0=1;
TR1=1;
a=b=12;
c=0;
TH0=TL0=255;
while(1)
{ for(c=0;c<=60;c++)
{if(c==60)
{c=0;b=b+1;
if(b==60)
{b=0;
a=a+1;
if(a==24)
{a=0;}
}
}
display(a,b,c);
delay1ms(1000);
}
}
}
void chushihua(void) interrupt 0 using 0
{a=b=12;
c=0;
display(a,b,c);
}
void TS(void) interrupt 1 using 1
{ a=a+1;
if(a==24)
{a=0;}
display(a,b,c);
}
void TF(void) interrupt 3 using 3
{ b=b+1;
if(b==60){b=0;}
display(a,b,c);
}
请大神们看看瞧这个程序,结果图在2楼
#define uchar unsigned char
#define uint unsigned int
uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar a,b,c;
void delay1ms(uint i)
{uchar j;
while(i--)
{ for(j=0;j<114;j++)
{;}
}
}
void display(uchar x,uchar y,uchar z)
{
P2=0XFE;
P0=tab[x/10];
delay1ms(1);
P2=0Xfd;
P0=tab[x%10];
delay1ms(1);
P2=0xfb;
P0=0xbf;
delay1ms(1);
P2=0XF7;
P0=tab[y/10];
delay1ms(1);
P2=0Xef;
P0=tab[y%10];
delay1ms(1);
P2=0XDF;
P0=0xbf;
delay1ms(1);
P2=0XbF;
P0=tab[z/10];
delay1ms(1);
P2=0X7F;
P0=tab[z%10];
delay1ms(1);
}
void main(void)
{EA=1;
TMOD=0X66;
ET0=1;
IT0=1;
IE0=1;
TR0=1;
TR1=1;
a=b=12;
c=0;
TH0=TL0=255;
while(1)
{ for(c=0;c<=60;c++)
{if(c==60)
{c=0;b=b+1;
if(b==60)
{b=0;
a=a+1;
if(a==24)
{a=0;}
}
}
display(a,b,c);
delay1ms(1000);
}
}
}
void chushihua(void) interrupt 0 using 0
{a=b=12;
c=0;
display(a,b,c);
}
void TS(void) interrupt 1 using 1
{ a=a+1;
if(a==24)
{a=0;}
display(a,b,c);
}
void TF(void) interrupt 3 using 3
{ b=b+1;
if(b==60){b=0;}
display(a,b,c);
}
请大神们看看瞧这个程序,结果图在2楼