51单片机键盘检测

  • 格式:txt
  • 大小:3.66 KB
  • 文档页数:2
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char code aa[16]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,0x7f,0x6f,
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{ case 0xee:num=0;break;
case 0xde:num=1;break;
while(P1!=0xfd);
temp=P1;
while(temp==0xfd)
{
delay(5);
temp=P1;
while(temp==0xfd)
sclk=0;
da=ss&ann;
sclk=1;
ann=ann>>1;
}
st=0;
st=1;
st=0;
}
void main()
{
while(1)
{
P1=0xfe;
while(temp==0xfe)
{delay(5);
temp=P1;
while(temp==0xfe)
{display(aa[num]);break;
case 0xbe:num=2;break;
case 0x7e:num=3;break;
} Leabharlann while(P1!=0xfe);
temp=P1;
{display(aa[num]);
break;
}
break;
}
temp=0xf0;
temp=P1&temp;
while(temp!=0xf0)
{
delay(5);
temp=0xf0;
temp=P1&temp;
case 0xdb:num=9;break;
case 0xbb:num=10;break;
case 0x7b:num=11;break;
}
while(P1!=0xfb);
temp=P1;
while(temp==0xf7)
{display(aa[num]);
break;
}
break;
}
break;}
}
}
break;
}
break;}
}
P1=0xfd;
temp=0xf0;
temp=P1&temp;
temp=0xf0;
temp=P1&temp;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{ case 0xe7:num=12;break;
case 0xd7:num=13;break;
break;}
}
P1=0xf7;
temp=0xf0;
temp=P1&temp;
while(temp!=0xf0)
{
delay(5);
0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit da=P2^5;//串行数据数输入
sbit st=P2^6;//锁存时钟
sbit sclk=P2^7;//移位时钟
uchar temp,ann;
int num;
void delay(int z)
{
unsigned int t1,y;
{display(aa[num]);
break;
}
break;
}
break;}
}
temp=P1&temp;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{ case 0xeb:num=8;break;
}
}
P1=0xfb;
temp=0xf0;
temp=P1&temp;
while(temp!=0xf0)
{
delay(5);
temp=0xf0;
temp=P1;
while(temp==0xfb)
{
delay(5);
temp=P1;
while(temp==0xfb)
for(t1=z;t1>0;t1--)
for(y=110;y>0;y--);
}
int i;
void display(uchar ss)
{
da=0;
P0=0x00;
ann=0x80;
da=0;
for(i=0;i<8;i++)
{
case 0xb7:num=14;break;
case 0x77:num=15;break;
}
while(P1!=0xf7);
temp=P1;
while(temp==0xf7)
{
delay(5);
switch(temp)
{ case 0xed:num=4;break;
case 0xdd:num=5;break;
case 0xbd:num=6;break;
case 0x7d:num=7;break;
}
while(temp!=0xf0)
{
delay(5);
temp=0xf0;
temp=P1&temp;
while(temp!=0xf0)
{
temp=P1;

下载文档原格式

  / 2