第1个回答 2017-01-04
#include <reg51.H>
sbit P3_5 =P3^5;
void delay()
{
unsigned char i,j;
for(j=20;j>0;j--)
for( i= 250;i>0;i--);
}
unsigned char code dispcode[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0x00};
unsigned char second;
unsigned char keycnt;
unsigned int tcnt;
void main(void)
{
unsigned char i,j;
TMOD=0x02;
ET0=1;
EA=1;
second=0;
P0=dispcode[second/10];
P2=dispcode[second%10];
TR0=1;
while(1)
{
if( second ==60)
{
TR0=0;
P1=0x5F;
delay();
P1=0xFF;
delay();
}
}
}
void t0(void) interrupt 1 using 0
{
tcnt++;
if(tcnt==4000)
{
tcnt=0;
second++;
P0=dispcode[second/10];
P2=dispcode[second%10];
}
}本回答被网友采纳