proteus仿真矩阵键盘时出现的问题,请帮忙看一下程序哪儿出错了
http://cwb.jaeer.com/content/uploads/tempimg/2012090411/1151048984.png...
http://cwb.jaeer.com/content/uploads/tempimg/2012090411/1151048984.png
展开
1个回答
展开全部
//我调试过的!
#include"reg52.h"
keyboard()
{
static unsigned char flg;
unsigned char temp;
P3=0xff;
P3=0xf0;
temp=P3;
if(temp!=0xf0)
{
P3=0xfe;
temp=P3;
switch(temp)
{
case(0xee):flg=3;break;
case(0xde):flg=2;break;
case(0xbe):flg=1;break;
case(0x7e):flg=0;break;
}
P3=0xfd;
temp=P3;
switch(temp)
{
case(0xed):flg=7;break;
case(0xdd):flg=6;break;
case(0xbd):flg=5;break;
case(0x7d):flg=4;break;
}
P3=0xfb;
temp=P3;
switch(temp)
{
case(0xeb):flg=11;break;
case(0xdb):flg=10;break;
case(0xbb):flg=9;break;
case(0x7b):flg=8;break;
}
P3=0xf7;
temp=P3;
switch(temp)
{
case(0xe7):flg=15;break;
case(0xd7):flg=14;break;
case(0xb7):flg=13;break;
case(0x77):flg=12;break;
}
}
else
{flg=16;}
return flg;
}
#include"reg52.h"
keyboard()
{
static unsigned char flg;
unsigned char temp;
P3=0xff;
P3=0xf0;
temp=P3;
if(temp!=0xf0)
{
P3=0xfe;
temp=P3;
switch(temp)
{
case(0xee):flg=3;break;
case(0xde):flg=2;break;
case(0xbe):flg=1;break;
case(0x7e):flg=0;break;
}
P3=0xfd;
temp=P3;
switch(temp)
{
case(0xed):flg=7;break;
case(0xdd):flg=6;break;
case(0xbd):flg=5;break;
case(0x7d):flg=4;break;
}
P3=0xfb;
temp=P3;
switch(temp)
{
case(0xeb):flg=11;break;
case(0xdb):flg=10;break;
case(0xbb):flg=9;break;
case(0x7b):flg=8;break;
}
P3=0xf7;
temp=P3;
switch(temp)
{
case(0xe7):flg=15;break;
case(0xd7):flg=14;break;
case(0xb7):flg=13;break;
case(0x77):flg=12;break;
}
}
else
{flg=16;}
return flg;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询