想让4位数码管能显示0-9999,但是第四位只能显示0,请大神帮忙看程序哪里有问题
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f,0x00};
void display(a0,b0,c0,d0);
scounter=(TH1*256+TL1)/5;
if(scounter<10)
{
a0=scounter;b0=10;c0=10;d0=10;
}
else
{
if(scounter<100)
{a0=scounter/10;b0=scounter%10;c0=10;d0=10;}
else
{
if(scounter<1000)
{a0=scounter/100;b0=scounter%100/10;c0=scounter%10;d0=10;}
else
{
if(scounter<10000&&scounter>=1000)
{a0=scounter/1000;b0=scounter%1000/100;c0=scounter%100/10;d0=scounter%10;}
}
}
}
display(a0,b0,c0,d0);
void display(uchar a,uchar b,uchar c,uchar d)
{
P0=table[a];
dula=1;
dula=0;
P0=0xfe;
wela=1;
wela=0;
delay(5);
P0=table;
dula=1;
dula=0;
P0=0xfd;
wela=1;
wela=0;
delay(5);
P0=table[c];
dula=1;
dula=0;
P0=0xfb;
wela=1;
wela=0;
delay(5);
P0=table[d];
dula=1;
dula=0;
P0=0xef;
wela=1;
wela=0;
delay(5);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>