我这个程序看了半天了,还没找到原因,请高手出山指点呵呵!:lol
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0xc0,0xf9,0xa4,0x30,0x99,0x92,
0x82,0xf8,0x80,0x90,0x7f};//段编码
uchar code wei[]={0x01,0x02,0x04,0x08,0x10,0x20};//位编码
delay(uchar);//定义延时子程序
display(uchar);//定义显示子程序
uchar scan();//定义按键检测子程序
sbit p10=P1^0;
sbit p11=P1^1;
sbit key1=P1^4;
sbit key2=P1^5;
sbit key3=P1^6;
sbit key4=P1^7;
uchar a,b,c,n,num;
void main()//主函数
{
while(1)
{
display(scan());
}
}
delay(uchar a)//延时子函数
{
for(b=a;b>0;b--)
for(c=100;c>0;c--);
}
display(uchar n)//显示子程序
{
P2=table[n];
p10=1;
p10=0;
P3=wei[5];
p11=1;
p11=0;
}
uchar scan()//按钮检测子程序
{
if(key1==0)
num=1;
if(key2==0)
num=2;
if(key3==0)
num=3;
if(key4==0)
num=4;
return num;
} |