51单片机 矩阵键盘,数码管显示。以下程序数码管不显示

我要做一个简易的计算器,现在的想法是通过按下矩阵键盘的按键,在数码管上显示出来。可以显示一位数、两位数、三位数······以下是简单的0、1、2、3按键
程序如下:
/***********************************
函数名称: Display
函数功能: 数码管显示
入口参数: 无
备注 :
***********************************/
void Display(uchar wei,uchar duan)
{
switch(wei)
{
case 1:
wei=0xfe;
break;
case 2:
wei=0xfd;
break;
case 3:
wei=0xfb;
break;
case 4:
wei=0xf7;
break;
case 5:
wei=0xef;
break;
case 6:
wei=0xdf;
break;
}
Dula=1;
P0=table[duan];
Dula=0;
P0=0xff;
Wela=1;
P0=wei;
Wela=0;
Delay(5);
}

/***********************************
函数名称: Keyscan()
函数功能: 键盘扫描
入口参数: 无
备注 :
***********************************/
void Keyscan()
{
uchar temp;
P3=0xfe;
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
Delay(10);
if(temp!=0xf0)
{
temp=P3;
switch(temp)
{
case 0xee: //0
Key=0;
Wei++;
break;
case 0xde: //1
Key=1;
Wei++;
break;
case 0xbe: //2
Key=2;
Wei++;
break;
case 0x7e: //3
Key=3;
Wei++;
break;
}
while(temp!=0xf0)
{
temp=P3;
P3=temp&0xf0;
//Beep=0;
}
//Beep=1;
Display(Wei,Key);
}
}
Display(Wei,Key);
}
}
}

void Main()
{
Wela=0;
Dula=0;
while(1)
{
Keyscan();
}
}
哪位帮忙给看看,没有想明白。。谢谢。。
不好意思,以上程序 Display(Wei,Key); 多写了一句。。

你用的郭天祥的板子?

正好前段时间帮别人做过数码管显示的计算器,我传你吧。

有不懂的地方回复我。

希望我的回答能帮助到你。

温馨提示:答案为网友推荐,仅供参考
相似回答