資源描述:
《單片機(jī)簡易密碼鎖 單片機(jī)密碼鎖程序》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、51單片機(jī)簡易密碼鎖51單片機(jī)密碼鎖程序?qū)ёx:就愛閱讀網(wǎng)友為您分享以下“51單片機(jī)密碼鎖程序”資訊,希望對您有所幫助,感謝您對92to.com的支持!關(guān)于“l(fā)cd1602密碼鎖...”的內(nèi)容本站搜索更多關(guān)于“l(fā)cd1602密碼鎖程序”的內(nèi)容這是我自己寫的一個密碼鎖,用數(shù)組存儲密碼,但是復(fù)位系統(tǒng)后,只要又一次輸入的密碼錯誤,后面就永遠(yuǎn)沒辦法開啟鎖,無論怎么輸入,顯示都是密碼錯誤,在此想請教一下各位高手#include<reg52.h>#include<intrins.h>#defineuintunsignedi
2、nt#defineucharunsignedcharuchartemp,s,j,w,f,a,t0,num;17ucharlcd[]=“ENTERPASSWORD:WRONGPASSWORD!GOODWORK!”;ucharlcd1[]=“0123456789ABCDEF”;ucharlcd3[]={‘1’,’2’,’3’,’4’,’5’,’6’};ucharlcd2[16];sbitRS=P2;sbitRW=P2;sbitE=P2;sbitbeep=P3;voidkeyscan();voidbegin();voiddelay
3、(uintz)//延時{uintx,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}voiddelay171(){_nop_();_nop_();_nop_();}ucharlcd_read_start()//讀取P0空狀態(tài){RW=1;delay1();RS=0;delay1();E=1;delay1();s=P0;delay1();E=0;delay1();RW=0;delay1();return(s);}voidlcd_write_cmd(ucharcom)//寫命令{uchar17i;d
4、o{i=lcd_read_start();i=i&0x80;delay(2);}while(i!=0);RW=0;delay1();RS=0;//RW=1,RS=0,寫LCD命令字delay1();E=1;//E端時序delay1();P0=com;//將com中的命令字寫入LCD數(shù)據(jù)口delay1();E=0;delay1();RW=1;delay(5);}voidlcd_write_dat(uchardat)//寫函數(shù){uchar17i;do{//查忙操作i=lcd_read_start();//調(diào)用讀狀態(tài)字函數(shù)i=i&0x80
5、;//與操作屏蔽掉低7位delay(2);}while(i!=0);//LCD忙,繼續(xù)查詢,否則退出循環(huán)RW=0;delay1();RS=1;//RW=1,RS=0,寫LCD命令字delay1();E=1;//E端時序delay1();P0=dat;//將dat中的顯示數(shù)據(jù)寫入LCD數(shù)據(jù)口delay1();E=0;delay1();RW=1;delay(5);}voidinitial(){lc17d_write_cmd(0x3c);lcd_write_cmd(0x0e);lcd_write_cmd(0x01);lcd_write_c
6、md(0x06);lcd_write_cmd(0x80);}voidinspect(){if(f!=0){initial();lcd_write_cmd(0x80);for(a=16;a<30;a++){lcd_write_dat(lcd[a]);delay(10);}w=0;//t0=0;//TR0=1;//17while(1);}else{initial();lcd_write_cmd(0x80);for(a=31;a<41;a++){lcd_write_dat(lcd[a]);delay(10);}w=0;//t0
7、=0;//lcd液晶初始化//功能設(shè)定//光標(biāo)//清屏指令//設(shè)定DDROM地址指令//TR0=1;//while(1);}}void//蜂鳴器{beep=0;delay(200);beep=1;}17voidjudge(){ucharc;if(w>16){w=0;beeps();lcd_write_cmd(0xc0);for(c=0;c<16;c++)lcd_write_dat(‘‘);}}voidscan(){uchar17b,d;if(num==15){w=0;begin();}if(num==14){w--;lc
8、d_write_cmd(0xc0+w);lcd_write_dat(‘‘);lcd2[w]=lcd2[w+2];lcd_write_cmd(0xc0+w);}if(num==12){for(a=0;a<6;a++){beeps(