一个单片机矩阵键盘的程序,在KEIL中编译出错,高手帮帮忙吧!

2024-12-26 18:57:18
推荐回答(5个)
回答1:


P0=Table[key];}} 和
void main()
之间再添个 }
你的代码太乱,最好写成规范的锯齿风格,就容易发现这种错误

回答2:

贴代码

回答3:

#include
unsigned char key;
unsigned char temp;
unsigned char code Table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x84};
void delay(unsigned x)
{unsigned char i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);}
void keydown()
{
P1=0xfe;
temp=P1;
temp=temp&0xf0;
if(temp!=0xf0)
{delay(10);
temp=P1;
temp=temp&0xf0;
}
if(temp!=0xf0)
{temp=P1;
switch(temp)
{
case 0xee:key=0;
break;
case 0xde:key=1;
break;
case 0xbe:key=2;
break;
case 0x7e:key=3;
break;
}
while(temp!=0xf0)
{temp=P1;
temp=temp&0xf0;}
P0=Table[key];
}
}
void main()
{P2=0x00;P2=0xff;
while(1){keydown();}}

回答4:


P0=Table[key];}} 和
void main()
之间再添个 }

回答5:

什么问题