char吧 关注:19贴子:49
  • 1回复贴,共1

矩阵式键盘P1赋0X0F与0XF0区别?

只看楼主收藏回复

#include<reg51.h>
#define uchar unsigned char
#define unit unsigned int
unsigned char kk,kn=16;
unsigned char const DSP[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,
0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
void main()
{
char tmp1;
//P0=0x00;
while(1)
{
P1=0X0F;//为何此处用0XF0时下机tmp!=0xF0会以为真呢,进行调用键盘扫描程序程序;而此处用0X0F时,
//不按键不会调用键盘扫描程序
tmp1=P1;
if(tmp1!=0X0F)keyscan();为何
if(kn!=kk)
{
P0=DSP[kk];
}
}
}
uchar Keyscan()
{
uchar i, j, temp,temp2, Buffer[4] = {0xef, 0xdf, 0xbf, 0x7f};
for(j = 0; j < 4; j++)
{ //????
P1 = Buffer[j]; //?P1????????????
temp = 0x01; //?????P1.0?
for(i = 0; i < 4; i++)
{ //????
temp2=P1;
if(!(temp2 & temp)) //?P1???,??1?
{
kk=(i+j*4);
break; //????????
}
temp <<= 1; //????,????
}
}
return kk; //????,?????,??16
}


IP属地:广东1楼2018-04-11 21:40回复
    矩阵式键盘程序,为何给P1赋0X0F0时,不按键(tmp1!=0xF0)为何会当真而调用keyscan()程序


    IP属地:广东2楼2018-04-11 21:44
    回复