程序代码如下:
#include<at89x52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit P27=P2^7;sbit P26=P2^6;
sbit P25=P2^5;sbit P24=P2^4;
uint js;
static uint i;
void delay(unsigned int ii)
{
unsigned int jj;
for(;ii>0;ii--)
for(jj=0;jj<125;jj++)
{;}
}
void delay500(unsigned int iii)
{
unsigned int jjj;
for(;iii>0;iii--)
for(jjj=0;jjj<60;jjj++)
{;}
}
void main(void)
{ TMOD=0X01;
TH0=0XB1;
TL0=0XE0;
ET0=1;EA=1;
TR0=1;
while(1)
{
for(i=0;i<=9999;i++)
{
js=i;
delay(500);
}
}
}
void time() interrupt 1 using 2
{
TL0=0xe0;
TH0=0xb1;
P27=0;
P0=smg[js/1000];
delay500(5);
P27=1;
P26=0;
P0=smg[js%1000/100];
delay500(5);
P26=1;
P25=0;
P0=smg[js%100/10];
delay500(5);
P25=1;
P24=0;
P0=smg[js%10];
delay500(5);
P24=1;
}
程序应该怎么加程序,应该加在哪里啊,才能使点不显示,前面多余的0不显示 |