1602电子密码锁c程序_第1页
1602电子密码锁c程序_第2页
1602电子密码锁c程序_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本文格式为Word版,下载可任意编辑——1602电子密码锁c程序#include

#defineucharunsignedchar#defineuintunsignedintsbitlcdrs=P2^4;//液晶数据、指令端sbitwr=P2^5;//读、写端sbitlcden=P2^6;//液晶使能端sbitspeaker=P2^3;//扬声器ucharcodetable[]={\ucharcodetable1[]={\ucharcodetable2[]={\welcome!!!\ucharcodetable4[]={\ucharcodetable5[]={\ucharcodetable6[]={\fuckyou!\ucharcodetable7[]={\getout!!\ucharcodetable8[]={\setsucceed\bitflag,flag1,flag2,flag3,flag4,flag5,rst;ucharkey,count;voiddelayms(uintx){uinti,j;for(i=x;i>0;i--)//延时函数for(j=110;j>0;j--);}

voidwrite_com(ucharcom)//液晶写指令函数{wr=0;lcdrs=0;P0=com;delayms(5);lcden=1;delayms(5);lcden=0;}

voidwrite_data(uchardate)//液晶写数据函数{wr=0;lcdrs=1;P0=date;delayms(5);lcden=1;delayms(5);lcden=0;}//液晶初始化函数voidlcdinit()

{lcden=0;write_com(0x38);write_com(0x06);write_com(0x0f);write_com(0x01);}

voidkeyscan()//键盘扫描函数{uchartemp;P1=0xfe;if(P1!=0xfe){delayms(8);if(P1!=0xfe){temp=0xf0switch(temp){case0xe0:key=0;flag5=1;break;?*?字符,把对应的数字放入数组中case0xd0:key=1;flag5=1;break;进数组,只是为了防止删减密码case0xb0:key=2;flag5=1;break;正确的密码中case0x70:key=3;flag5=1;break;}while(P1!=0xfe);write_data('*');count++;}}P1=0xfd;if(P1!=0xfd){delayms(8);if(P1!=0xfd){temp=0xf0switch(temp){case0xe0:key=4;flag5=1;break;

//数字键盘按下时显示//flag5为1时才能把数据放//时把key的值装进已输入

case0xd0:key=5;flag5=1;break;case0xb0:key=6;flag5=1;break;case0x70:key=7;flag5=1;break;}while(P1!=0xfd);write_data('*');count++;}}P1=0xfb;if(P1!=0xfb){delayms(8);if(P1!=0xfb){temp=0xf0switch(temp){case0xe0:key=8;write_data('*');flag5=1;count++;break;case0xd0:key=9;write_data('*');flag5=1;count++;break;case0xb0:flag=1;break;case0x70:rst=1;break;}while(P1!=0xfb);}}P1=0xf7;if(P1!=0xf7){delayms(8);if(P1!=0xf7){temp=0xf0switch(temp){case0xe0:switch(count){case1:write_com(0xc5);write_data('');write_com(0xc5);break;当按下clean键时,往前一个地址显示空字符,case2:write_com(0xc6);write_data('');write_com(0xc6);break;再把指针指回前一个地址case3:write_com(0xc7);write_data('');write_com(0xc7);break;case4:write_com(0xc8);write_data('');write_com(0xc8);break;

////

case5:write_com(0xc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论