#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp;
uchar key();
void main()
{
while(1)
{
key();
}
}
uchar key()
{
P1=0xfe;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xee:P0=0xfe;
break;
case 0xde:P0=0xfd;
break;
case 0xbe:P0=0xfb;
break;
case 0x7e:P0=0xf7;
break;
}
temp=temp&0xf0;
}
}
P1=0xfd;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xed:P0=0xef;
break;
case 0xdd:P0=0xdf;
break;
case 0xbd:P0=0xbf;
break;
case 0x7d:P0=0x7f;
break;
}
temp=temp&0xf0;
}
}
P1=0xfb;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xeb:P3=0xfe;
break;
case 0xdb:P3=0xfd;
break;
case 0xbb:P3=0xfb;
break;
case 0x7b:P3=0xf7;
break;
}
temp=temp&0xf0;
}
}
P1=0xf7;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xe7:P3=0xef;
break;
case 0xd7:P3=0xdf;
break;
case 0xb7:P3=0xbf;
break;
case 0x77:P3=0x7f;
break;
}
temp=temp&0xf0;
}
}
}
关于键盘的简单使用
最新推荐文章于 2023-03-08 16:03:04 发布