【正文】
relay=1。 鹽城工學(xué)院課程設(shè)計(jì)說(shuō)明書(shū)( 20xx) 52 relay=1。 case 22: //按 E鍵消除所有輸入 i=0。 DSY_BUFFER[6]=0。 Display_String(Newcode confirm ,0x80)。 Display_String(Password Saved! ,0xc0)。 // Display_String( ,0xc0)。k++) { Userpassword[k]=Userpassword[k]+48。 //密碼校驗(yàn)位置 1 delayms(5)。 case 16: //按 D鍵保存新密碼 if ( !IS_valid_user) { i=0。 Display_String( ==No rights !== ,0xc0)。 relay=1。 //關(guān)閉 LED clear_password()。 //開(kāi)鎖 clear_password()。 case 12: //按 Enter 鍵開(kāi)鎖 for(k=0。 } break。 if(P1!=0x0f) {delayms(10)。 init()。 case 1:keynum+=12。 delayms(5)。 case 2:keynum=4。i++) { DSY_BUFFER[i]=39。 return 1。 } uchar Sendstring(uchar slave,uchar subaddr,uchar *buffer,uchar n) { uchar i。 for(i=0。 delay4us()。 scl=0。 for(i=0。 delay4us()。 } uchar recbyte() { uchar i,rd。 delay4us()。 delay4us()。 delay4us()。 write_(0x0c)。 lcden=0。 lcden=0。 } void delay() //短延時(shí),兩個(gè)機(jī)器周期 ,做總線的延時(shí)用 {。 uchar code table2[]=123456。 uchar DSY_BUFFER1[16]= 。 uchar buffer[6]={0}。除上述基本的密碼鎖功能外,還有 聲音提示等功能,依據(jù)實(shí)際的情況還可以添加遙控功能。當(dāng)不小心輸錯(cuò)密碼時(shí),可以退格將輸錯(cuò)的位清除,退格一次密碼的位數(shù)減一位,同時(shí)顯示器上的 “*”個(gè)數(shù)也減 1。這樣做可以避免因?yàn)閼糁魍浲顺鱿到y(tǒng)而使他人有機(jī)可乘。 (3)讀順序地址內(nèi)容。 三種不同的讀操作方式為:讀當(dāng)前地址內(nèi)容(立即地址讀取)、讀隨機(jī)地址內(nèi)容(隨機(jī)地址讀?。┖妥x順序地址內(nèi)容(順序地址讀?。?。 (1)字節(jié)寫。雖然顯示子程序很多,但是由于其顯示原理都一樣,所以我就不一一介紹各個(gè)子程序了,只要能夠熟練使用 LCD1602 各個(gè)指令,這些大同小異的子程序也就不在話下了。 本設(shè)計(jì)中各按鍵對(duì)應(yīng)鍵值如表 41 所示。如果列的數(shù)值全部為 1,說(shuō)明沒(méi)有鍵被按下,否則說(shuō)明有鍵被按下。 當(dāng)用戶輸入密碼錯(cuò)誤次數(shù)達(dá)到預(yù)設(shè)警告次數(shù)時(shí),系統(tǒng)調(diào)用報(bào)警子程序,使蜂鳴器發(fā)出報(bào)警音,同時(shí)禁止鍵盤輸入。如圖 39 所示。當(dāng)密碼輸入完成時(shí),按下確認(rèn)鍵,如果輸入的密碼正確的話, LCD 顯示“OK”,單片機(jī)其中 引腳會(huì)輸出低電平,使三極管 T2 導(dǎo)通,電磁鐵吸合,繼電器開(kāi)關(guān)跳轉(zhuǎn),電子密碼鎖被打開(kāi),如果密碼不正確, LCD 顯示屏?xí)@示“ you are thief! ”, 輸出的是高電平,電子密碼鎖不能打開(kāi)。首先辨別鍵盤中有無(wú)按鍵被按下,在單片機(jī) I/O口向鍵盤送全掃描字,然后讀入行線狀態(tài)來(lái)判斷。如 圖34所示。因而,復(fù)位是一個(gè)很重要的操作方式。 (2)采用 LCD 顯示單元,提高了可讀性 ,提供良好的人機(jī)界面。 20世紀(jì) 80年代以來(lái),隨著各種電子集成電路的出現(xiàn),特別是單片機(jī)的面世,電子密碼鎖得到了很大的發(fā)展。但是,時(shí)代在發(fā)展,社會(huì)在進(jìn)步,任何事物只有不斷地進(jìn)步才能適應(yīng)時(shí)代發(fā)展的需求。經(jīng)過(guò)若干年的使用和研究,人們對(duì)鎖具的結(jié)構(gòu)、機(jī)理也了解得相當(dāng)透徹了,因此,不使用鑰匙就能將鎖打開(kāi)的方法也層出不窮。無(wú)論是開(kāi)鎖還是更改密碼,只要識(shí)字的人都能夠直接使用,使用方法簡(jiǎn)單而不繁瑣。 在本次基于單片機(jī)的電子密碼鎖設(shè)計(jì)中,將采用 AT89C51 單片機(jī)作為控制核心,配合相應(yīng)的電路和軟 件程序,實(shí)現(xiàn)密碼的輸入和修改、信息的顯示、鍵盤的鎖定、系統(tǒng)報(bào)警、開(kāi)鎖和閉鎖等功能。 單片機(jī)課程設(shè)計(jì)說(shuō)明書(shū) 電子密碼鎖控制系統(tǒng)設(shè)計(jì) 專業(yè) 電氣工程及其自動(dòng)化 學(xué)生姓名 張海嘯 班級(jí) B 電氣 104 學(xué)號(hào) 1010601410 指導(dǎo)教師 張?zhí)m紅 完成日期 20xx 年 6 月 15 日 鹽城工學(xué)院課程設(shè)計(jì)說(shuō)明書(shū)( 20xx) 1 摘 要 : 鎖是指加在門、箱子、抽屜等物體上的封緘器,要用專用的鑰匙才能打開(kāi)。在設(shè)計(jì)中, 利用識(shí)別密碼是否正確來(lái)開(kāi)鎖或報(bào)警,通過(guò)串行存儲(chǔ)器 AT24C02 來(lái)實(shí)現(xiàn)密碼的修改和存儲(chǔ) 關(guān)鍵詞 :單片機(jī);密碼鎖;矩陣鍵盤;掉電存儲(chǔ) The Design Of Electronic Code Lock Based On Single Chip Microputer Abstract: As sealed device, the lock added to such objects like door, box, drawer etc, can be opened with specified key. Since the ancient time, lock is a kind of security, guaranteeing people’s property safety even life safety. With the development of human history and more attention paid to property safety and life safety, various multifunctional locks can be seen in the world. Traditional mechanical locks people use in life are gradually replaced by electronic bination lock characterized with better safety performance and more functions. In the modern society, electronic bination lock is a noun familiar to everyone. Usually, the door of munity is equipped with electronic bination lock. This paper will introduce an electronic bination lock. This lock controls the electric circuits and the performance of chips by identifying password. Thus, the openness and closeness of the lock can be controlled, and the task of electronic lock device can be pleted. This design is about bination lock, based on the AT89C51 singlechip microputer as the core of controlling goals. This design in which the AT89C51 singlechip microputer as the core of the controlling goals cooperated with relevant circuits and software programs can achieve such functions like password input and modification, information display, keyboard locking, warning system, and the openness and closeness of the lock etc. In this design, the openness of lock and alarming are 鹽城工學(xué)院課程設(shè)計(jì)說(shuō)明書(shū)( 20xx) 2 according to identifying the password, and password revision and storage is achieved by the function of the AT24C02 serial storage. Keywords: Singlechip microputer, Combination lock, Electronic lock, Matrix keyboard, Power lost storage 鹽城工學(xué)院課程設(shè)計(jì)說(shuō)明書(shū)( 20xx) 3 目錄 緒 論 ............................................................. 4 電子密碼鎖簡(jiǎn)介 .................................................... 5 電子密碼鎖設(shè)計(jì)的背景及意義 ........................................ 5 電子密碼鎖 的現(xiàn)狀及 發(fā)展趨勢(shì) ........................................ 6 1 課題設(shè)計(jì)目標(biāo) .................................................... 6 2 總體設(shè)計(jì)方案 .................................................... 6 設(shè)計(jì)思路 ...................................................... 6 方案確立 ...................................................... 7 3 硬件電路方框圖 .................................................. 7 單片機(jī)及其最小系統(tǒng) ............................................ 7 復(fù)位電路的設(shè)計(jì) ............................................ 8 時(shí)鐘 電路的設(shè)計(jì) ............................................ 9 密碼鎖電路 ................................................... 10 按鍵電路的設(shè)計(jì) ........................................... 10 LCD 顯示電路 ............................................. 11 開(kāi)鎖機(jī)構(gòu) .....................