完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
#include
#define uchar unsigned char #define uint unsigned int ***it c1=P0^0; uchar temp,num,i; uchar code pass[]={0,1,2,3}; uchar mima[5]; void delay(uint z); uchar keyscan(); void main() { c1=0; while(1) { for(i=0;i<4;i++) { mima[i]=keyscan(); } if(mima[0]==pass[0]&&mima[1]==pass[1]&&mima[2]==pass[2]&&mima[3]==pass[3]) { c1=1;//打开继电器 } } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } /*键盘扫描*/ uchar keyscan() { P1=0xfe; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { delay(10); P1=0xfe; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { temp=P1; switch(temp) { case 0xee:num=0;break; case 0xde:num=1;break; case 0xbe:num=2;break; case 0x7e:num=3;break; } if(temp!=0xf0) { temp=P1; temp=temp&0xf0; } } } P1=0xfd; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { delay(10); P1=0xfd; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { temp=P1; switch(temp) { case 0xed:num=4;break; case 0xdd:num=5;break; case 0xbd:num=6;break; case 0x7d:num=7;break; } if(temp!=0xf0) { temp=P1; temp=temp&0xf0; } } } P1=0xfb; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { delay(10); P1=0xfb; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { temp=P1; switch(temp) { case 0xeb:num=8;break; case 0xdb:num=9;break; case 0xbb:num=10;break; case 0x7b:num=11;break; } if(temp!=0xf0) { temp=P1; temp=temp&0xf0; } } } P1=0xf7; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { delay(10); P1=0xf7; temp=P1; temp=temp&0xf0; if(temp!=0xf0) { temp=P1; switch(temp) { case 0xe7:num=12;break; case 0xd7:num=13;break; case 0xb7:num=14;break; case 0x77:num=15;break; } if(temp!=0xf0) { temp=P1; temp=temp&0xf0; } } } return num; } |
|
相关推荐
1个回答
|
|
|
请上QQ52529158上送资料给你
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
435 浏览 0 评论
464 浏览 0 评论
450 浏览 0 评论
806 浏览 0 评论
RT-Thread与英飞凌(infineon)合作得板子PSOC 6 板子学习
748 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
17011 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 04:33 , Processed in 0.587683 second(s), Total 76, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1805