基于单片机AT89C51的电子密码锁设计
ay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
/*键盘扫描 逐行扫描*/
uchar keyscan()
{
uchar temp;
uchar num=No_key;
KEY=0xfe;
temp=KEY;
temp=temp&0xf0;
while(temp !=0xf0)
{
delay(5);
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=KEY;
switch(temp)
{
case 0xee:num=1;
break;
case 0xde:num=2;
break;
case 0xbe:num=3;
break;
case 0x7e:num=10;
break;
}
while(temp!=0xf0)
{
temp=KEY;
temp=temp&0xf0;
}
}
}
KEY=0xfd;
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
delay(5);
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=KEY;
switch(temp)
{
case 0xed:num=4;
break;
case 0xdd:num=5;
break;
case 0xbd:num=6;
break;
case 0x7d:num=11;
break;
}
while(temp!=0xf0)
{
temp=KEY;
temp=temp&0xf0;
}
}
}
KEY=0xfb;
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
delay(5);
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=KEY;
switch(temp)
{
case 0xeb:num=7;
break;
case 0xdb:num=8;
break;
case 0xbb:num=9;
break;
case 0x7b:num=12;
break;
}
while(temp!=0xf0)
{
temp=KEY;
temp=temp&0xf0;
}
}
}
KEY=0xf7;
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
delay(5);
temp=KEY;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=KEY;
switch(temp)
{
case 0xe7:num=0;
break;
case 0xd7:num=13;
break;
case 0xb7:num=14;
break;
case 0x77:num=15;
break;
}
while(temp!=0xf0)
{
temp=KEY;
temp=temp&0xf0;
}
}
}
return num;
}
单片机AT89C51电子密码 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)