现在问题是前两位只是闪烁一下就没了然后最后一位一直亮着
#include<reg52.h>
int flag,a;
sbit dula=P2^6;
sbit wela=P2^7;
char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07
,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void dispay(int a);
void delayms(int xms)
{
int i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void inti()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
REN=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
}
void main()
{
inti();
while(1)
{
if(flag==1)
{
dispay(a);
flag=0;
ES=1;
}
}
}
void dispay(int a)
{
int b,s,g;
b=a/100;
s=a%100/10;
g=a%10;
dula=1;
P0=table[b];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;
wela=0;
delayms(1);
dula=1;
P0=table[s];
dula=0;
P0=0xff;
wela=1;
P0=0xfd;
wela=0;
delayms(1);
dula=1;
P0=table[g];
dula=0;
P0=0xff;
wela=1;
P0=0xfb;
wela=0;
delayms(1);
}
void ser() interrupt 4
{
RI=0;
a=SBUF;
flag=1;
}
此帖出自
小平头技术问答
一周热门 更多>