程序如下
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code ge[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x90};
uchar code zixingma[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x90};
sbit P10=P1^0;
sbit P11=P1^1;
uchar s,k;
void delay5ms()
{
uchar i,j;
for(i=10;i>0;i--)
for(j=248;j>0;j--);
}
void t_0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
k--;
if(k==0)
{
k=20;
s--;
if(s==0)
{
s=60;
}
}
}
void main()
{
uint t;
s=60;
k=20;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
P11=1;
P0=zixingma[s/10];
for(t=0;t<10;t++);
delay5ms();
P10=1;
P11=0;
P0=zixingma[s%10];
}
} |