毕业设计(论文)-LCD遥控密码锁的设计与制作.doc_第1页
毕业设计(论文)-LCD遥控密码锁的设计与制作.doc_第2页
毕业设计(论文)-LCD遥控密码锁的设计与制作.doc_第3页
毕业设计(论文)-LCD遥控密码锁的设计与制作.doc_第4页
毕业设计(论文)-LCD遥控密码锁的设计与制作.doc_第5页
已阅读5页,还剩45页未读 继续免费阅读

下载本文档

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

文档简介

湖南机电职业技术学院 遥控密码锁 0 湖南机电职业技术学院湖南机电职业技术学院 HUNAN MECHANICAL sbit scl=P24; sbit fuwei=P36; sbit KAI=P10; sbit lcden=P27; sbit lcdrs=P26; sbit w1=P20; sbit w2=P21; sbit w3=P22; sbit w4=P23; uchar num,n=0,temp,count4,flag,date,r;/r 记录错误次数 uchar mima4; uchar yuanmima4; uchar tab_key4; bit mimaflag;/密码正确与否的标志 bit xiugaiflag;/修改密码标志 bit enter1flag;/确认密码修改 unsigned char KeyValue; void delay() ; void key_scan(); void key_scan1(); void DELAY(uint DELAY) uint h; 湖南机电职业技术学院毕业设计(论文) for(;DELAY0;DELAY-) for(h=0;h110;h+) ; void msgbox(unsigned char MODE,unsigned char DATA)/选择写数据 or 命令 0 为命令 1 为数据 P0=DATA; if(0=MODE) lcdrs=0;/写命令 else lcdrs=1;/写数据 DELAY(5); lcden=1; DELAY(5); lcden=0; void lcdchar(unsigned char add,unsigned char ch) if(0!=add) msgbox(0,add); 湖南机电职业技术学院毕业设计(论文) msgbox(1,ch); void lcdstring(unsigned char add,unsigned char *str) int I; msgbox(0,add); for(I=0;*(str+I)!=0I+) msgbox(1,*(str+I); DELAY(2); void initlcd() lcden=0; msgbox(0,0 x38); /显示模式设置 16*2 5*7 8 位 msgbox(0,0 x0c); /开关光标显示设置 msgbox(0,0 x06);/指针自动+1 msgbox(0,0 x01);/清屏 msgbox(0,0 x80);/0 x80+0 x10 /* 湖南机电职业技术学院毕业设计(论文) void start() /开始信号 sda=1; delay(); scl=1; delay(); sda=0; delay(); void stop() /停止 sda=0; delay(); scl=1; delay(); sda=1; delay(); void respons() /应答 uchar i; scl=1; delay(); while(sda=1) scl=0; delay(); 湖南机电职业技术学院毕业设计(论文) void init() /SHU SHI sda=1; delay(); scl=1; delay(); void write_byte(uchar date) /写到 24c02 uchar i,temp; temp=date; for(i=0;i8;i+) temp=temp1; scl=0; delay(); sda=CY; delay(); scl=1; delay(); scl=0; delay(); sda=1; 湖南机电职业技术学院毕业设计(论文) delay(); uchar read_byte() uchar i,k; scl=0; delay(); sda=1; delay(); for(i=0;i8;i+) scl=1; delay(); k=(k1)|sda; scl=0; delay(); return k; void write_add(uchar address,uchar date) /从单元写 start(); write_byte(0 xa0); respons(); write_byte(address); respons(); write_byte(date); respons(); 湖南机电职业技术学院毕业设计(论文) stop(); uchar read_add(uchar address) /从单元读 start(); write_byte(0 xa0); respons(); write_byte(address); respons(); start(); write_byte(0 xa1); respons(); date=read_byte(); stop(); return date; void mimacmp() uchar i0,i1,i2,i3; i0=i1=i2=i3=0; if(mima0=tab_key0) i0=1; if(mima1=tab_key1) i1=1; if(mima2=tab_key2) 湖南机电职业技术学院毕业设计(论文) i2=1; if(mima3=tab_key3) i3=1; flag=i0*i1*i2*i3; /全为 1 密码正确 void key_manage1() tab_keyn=0; n+; if(xiugaiflag=1) mimacount4=0; count4+; void key_manage2() tab_keyn=1; n+; if(xiugaiflag=1) mimacount4=1; 湖南机电职业技术学院毕业设计(论文) count4+; void key_manage3() tab_keyn=2; n+; if(xiugaiflag=1) mimacount4=2; count4+; void key_manage4() tab_keyn=3; n+; if(xiugaiflag=1) mimacount4=3; count4+; void key_manage5() 湖南机电职业技术学院毕业设计(论文) xiugaiflag=1; n=0; void c02int()/24c02 初始化 init(); write_add(1,0); DELAY(100); /init(); write_add(10,0); DELAY(100); / init(); write_add(20,0); DELAY(100); / init(); write_add(30,0); DELAY(100); void key_manage6() /确认件 if(enter1flag=1) c02int(); init(); 湖南机电职业技术学院毕业设计(论文) write_add(1,mima0); DELAY(100); / init(); write_add(10,mima1); DELAY(100); / init(); write_add(20,mima2); DELAY(100); / init(); write_add(30,mima3); DELAY(100); yuanmima0=mima0=read_add(1); DELAY(100); yuanmima1=mima1=read_add(10); DELAY(100); yuanmima2=mima2=read_add(20); DELAY(100); yuanmima3=mima3=read_add(30); DELAY(100); enter1flag=xiugaiflag=0; DELAY(1000); KAI=0; lcdstring(0 x80, PASSWORD RENEW ); DELAY(1000); lcdstring(0 x80,INPUT THE PASS); lcdstring(0 x80+0 x40, WODE: _ ); 湖南机电职业技术学院毕业设计(论文) void readmima() DELAY(100); yuanmima0=mima0=read_add(1); DELAY(100); yuanmima1=mima1=read_add(10); DELAY(100); yuanmima2=mima2=read_add(20); DELAY(100); yuanmima3=mima3=read_add(30); DELAY(100); void intmima() /初始化密码 3333 DELAY(100); write_add(1,3); DELAY(100); write_add(10,3); DELAY(100); write_add(20,3); DELAY(100); write_add(30,3); DELAY(100); 湖南机电职业技术学院毕业设计(论文) void gaimimacmp() uchar i0,i1,i2,i3; i0=i1=i2=i3=0; if(mima0=yuanmima0) i0=1; if(mima1=yuanmima1) i1=1; if(mima2=yuanmima2) i2=1; if(mima3=yuanmima3) i3=1; flag=i0*i1*i2*i3;/比较结果 1 为正确 void main() w1=w2=w3=w4=0; n=flag=r=KAI=0; readmima(); DELAY(30); initlcd(); lcdstring(0 x80,INPUT THE PASS );/开始显示输入密码 lcdstring(0 x80+0 x40, WODE: _ ); while(P3=0 xff 湖南机电职业技术学院毕业设计(论文) while(1) key_scan1(); key_scan(); if(xiugaiflag=1) if(count4=1) lcdchar(0 x80+0 x48,*); while(P3=0 xff if(count4=2|count4=3) lcdchar(0,*); while(P3=0 xff if(count4=4) lcdchar(0,*); DELAY(10); msgbox(0,0 x01);/清屏 flag=0; gaimimacmp(); n=count4=0; if(flag=1) enter1flag=1; flag=n=0; lcdstring(0 x80,CHANGE PASSWORD ); elseif(enter1flag=1) 湖南机电职业技术学院毕业设计(论文) lcdstring(0 x80,PRESS THE ENTER); else flag=n=0;/不正确事件 lcdstring(0 x80, WRONG POSSWORD ); DELAY(1000); xiugaiflag=0; lcdstring(0 x80,INPUT THE PASS); lcdstring(0 x80+0X40, WODE: _ ); /修改密码键没按下 if(xiugaiflag=0) if(n=1) lcdchar(0 x80+0 x48,*);/星号显示 while(P3=0 xff if(n=2|n=3) lcdchar(0,*); while(P3=0 xff if(n=4) lcdchar(0,*); msgbox(0,0 x01);/清屏 mimacmp(); 湖南机电职业技术学院毕业设计(论文) n=0; if(flag=1) lcdstring(0 x80,password is right); DELAY(1000); lcdstring(0 x80,INPUT THE PASS); lcdstring(0 x80+0X40, WODE: _ ); KAI=!KAI; r=0; flag=n=0; else lcdstring(0 x80,WRONG POSSWORD); r=r+1; /错误次数记录 DELAY(1000);/显示到重新输入 if(r=3) /判断 3 次 while(1) msgbox(0,0 x01); lcdstring(0 x80, Three errors ); while(1); lcdstring(0 x80,INPUT THE PASS); lcdstring(0 x80+0 x40, WODE: _ ); 湖南机电职业技术学院毕业设计(论文) void key_scan() if(P3!=0Xff) temp=P3; while(P3!=0Xff) switch(temp) case 0 xfe: key_manage1(); break; case 0 xfd: key_manage2(); break; case 0 xfb: key_manage3(); break; case 0 xf7: key_manage4(); break; 湖南机电职业技术学院毕业设计(论文) case 0 xef: key_manage5();

温馨提示

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

评论

0/150

提交评论