欢迎来到天天文库
浏览记录
ID:38573748
大小:30.00 KB
页数:13页
时间:2019-06-15
《【精品】电子密码锁》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、#include#include#include#defineucharunsignedcharuchardatekey;sbitRS=P2^0;sbitRW=P2^1;sbitE=P2^7;sbitSET=P3^2;sbitLock_BIT=P3^3;sbitSPK=P3^4;voidLCD_Initial();/初始化声明voidWRCMD(ucharj);voidWRdate(ucharj);voidGotoXY(uchari,ucharj);voi
2、dShow_1_Char(ucharucChar);voidShow_Char(ucharucaChar[]);voiddelay(ucharm);voiddelay1ms(intt);#defineC02_write0xa0#defineC02_read0xa1/-------------------------------------------#defineA0x0a/输入密码#defineB0x0b/修改密码#defineenter0x0c#definebackspace0x0fucharidatatemp
3、5_password[6]={0x01,0x02,0x03,0x04,0x05,0x06};/设置出厂密码“123456”/=======================LCD驱动函数=================================================================/*********************初始化函数********************************/voidLCD_Initial(){WRCMD(0x01);WRCMD(0x38);W
4、RCMD(0x0c);WRCMD(0x06);}/*********************LCD写命令函数********************************/voidWRCMD(ucharj){P0=j;E=0;delay(5);E=1;delay(5);RS=0;RW=0;E=0;delay(5);}/**********************写数据函数*********************************/voidWRdate(ucharj){P0=j;E=0;delay(5);E
5、=1;delay(5);RS=1;RW=0;E=0;delay(5);}/**********************写一个字符到LCD******************************/voidShow_1_Char(ucharucChar){WRdate(ucChar);}/**********************写一组字符到LCD*******************************/voidShow_Char(ucharucaChar[]){ucharucCount;for(ucCou
6、nt=0;;ucCount++){Show_1_Char(ucaChar[ucCount]);if(ucaChar[ucCount]==' ')break;}}/*********************设置字符(串)显示的首地址*******************************************/voidGotoXY(uchari,ucharj){if(j==0){WRCMD(0x80+i);}if(i==0){WRCMD(0xc0+j);}if(j==0&&i==0){WRCMD(0x80)
7、;}}voiddelay(ucharm)/延时函数{ucharx,y;for(x=0;x8、delay10ms(){uchari,j;for(i=20;i>0;i--)for(j==248;j>0;j--);}voiddelaywait()/等待{_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();}/====================发起始信号===================
8、delay10ms(){uchari,j;for(i=20;i>0;i--)for(j==248;j>0;j--);}voiddelaywait()/等待{_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();}/====================发起始信号===================
此文档下载收益归作者所有