單片機(jī)課程設(shè)計(jì)報(bào)告參考_第1頁(yè)
單片機(jī)課程設(shè)計(jì)報(bào)告參考_第2頁(yè)
單片機(jī)課程設(shè)計(jì)報(bào)告參考_第3頁(yè)
單片機(jī)課程設(shè)計(jì)報(bào)告參考_第4頁(yè)
單片機(jī)課程設(shè)計(jì)報(bào)告參考_第5頁(yè)
已閱讀5頁(yè),還剩42頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

單片機(jī)原理與應(yīng)用課程設(shè)計(jì)報(bào)告課程設(shè)計(jì)名稱:電子密碼鎖的設(shè)計(jì)專業(yè)班級(jí):學(xué)生姓名:學(xué)號(hào):指導(dǎo)教師:設(shè)計(jì)時(shí)間:成績(jī):信電工程學(xué)院徐州工程學(xué)院?jiǎn)纹瑱C(jī)原理及應(yīng)用課程設(shè)計(jì)目錄1緒論 11.1電子密碼鎖簡(jiǎn)介 11.2電子密碼鎖的背景與研究意義 11.3電子密碼鎖的現(xiàn)狀及發(fā)展趨勢(shì) 12系統(tǒng)整體方案設(shè)計(jì) 22.1設(shè)計(jì)目標(biāo) 22.2系統(tǒng)的基本方案 22.2.1系統(tǒng)方案選擇 22.2.2各模塊方案選擇 32.3主要元器件介紹 32.3.1STC89C52的簡(jiǎn)介 32.3.2LCD12864的簡(jiǎn)介 43系統(tǒng)的硬件設(shè)計(jì)與實(shí)現(xiàn) 53.1系統(tǒng)硬件概述 53.2主要單元電路的設(shè)計(jì) 53.2.1鍵盤(pán)掃描模塊電路的設(shè)計(jì) 53.2.2單片機(jī)控制模塊電路的設(shè)計(jì) 53.2.3報(bào)警模塊電路的設(shè)計(jì) 63.2.4LCD12864顯示模塊電路的設(shè)計(jì) 74系統(tǒng)的軟件設(shè)計(jì)與實(shí)現(xiàn) 84.1KEIL軟件介紹 84.2系統(tǒng)程序設(shè)計(jì)流程圖 84.2.1主程序軟件設(shè)計(jì) 84.2.2按鍵軟件設(shè)計(jì) 94.2.3密碼設(shè)置軟件設(shè)計(jì) 94.2.4開(kāi)鎖軟件設(shè)計(jì) 105系統(tǒng)仿真設(shè)計(jì) 125.1Proteus軟件介紹 125.2Proteus仿真圖 125.3硬件調(diào)試 135.4調(diào)試結(jié)果 136結(jié)論 14參考文獻(xiàn) 15附錄 16附錄1硬件實(shí)物圖 16附錄2C語(yǔ)言源程序 16徐州工程學(xué)院?jiǎn)纹瑱C(jī)原理及應(yīng)用課程設(shè)計(jì)PAGE51緒論1.1電子密碼鎖簡(jiǎn)介電子密碼鎖是一種通過(guò)密碼輸入來(lái)控制電路或是芯片工作,從而控制機(jī)械開(kāi)關(guān)的閉合,完成開(kāi)鎖、閉鎖任務(wù)的電子產(chǎn)品。它的種類很多,有簡(jiǎn)易的電路產(chǎn)品,也有基于芯片的性價(jià)比較高的產(chǎn)品?,F(xiàn)在應(yīng)用較廣的電子密碼鎖是以芯片為核心,通過(guò)編程來(lái)實(shí)現(xiàn)的。其性能和安全性已大大超過(guò)了機(jī)械鎖。1.2電子密碼鎖的背景與研究意義 在日常的生活和工作中,住宅與部門(mén)的安全防范、單位的文件檔案、財(cái)務(wù)報(bào)表以及一些個(gè)人資料的保存多以加鎖的辦法來(lái)解決。若使用傳統(tǒng)的機(jī)械式鑰匙開(kāi)鎖,人們常需攜帶多把鑰匙,使用極不方便,且鑰匙丟失后安全性即大打折扣。隨著科學(xué)技術(shù)的不斷發(fā)展,人們對(duì)日常生活中的安全保險(xiǎn)器件的要求越來(lái)越高。為滿足人們對(duì)鎖的使用要求,增加其安全性,用密碼代替鑰匙的密碼鎖應(yīng)運(yùn)而生。密碼鎖具有安全性高、成本低、功耗低、易操作等優(yōu)點(diǎn)。電子工業(yè)的迅速發(fā)展,數(shù)字電子技術(shù)已經(jīng)深入到了人們生活的各個(gè)層面,在國(guó)內(nèi)外各種各樣的電子產(chǎn)品也正在日新月異地向著高精尖技術(shù)發(fā)展。在安全技術(shù)防范領(lǐng)域,具有防盜報(bào)警功能的電子密碼鎖代替?zhèn)鹘y(tǒng)的機(jī)械式密碼鎖,克服了機(jī)械式密碼鎖密碼量少、安全性能差的缺點(diǎn),使密碼鎖無(wú)論在技術(shù)上還是在性能上都大大提高一步。1.3電子密碼鎖的現(xiàn)狀及發(fā)展趨勢(shì)當(dāng)今電子密碼鎖發(fā)展已經(jīng)到了非常高的境界,由于電子元件特別是單片機(jī)應(yīng)用在這幾年得到空前發(fā)展,無(wú)論功能性,穩(wěn)定性都比較全面,在保密方面已做到人眼識(shí)別,指紋識(shí)別,人聲識(shí)別基本上電影上有的現(xiàn)實(shí)也有。在國(guó)外發(fā)展比較早,所以應(yīng)用也比較廣泛,主要在家庭裝較貴重地方,銀行,保險(xiǎn)柜等應(yīng)用較多,在國(guó)內(nèi)這方面發(fā)展也較快,不管自己開(kāi)發(fā)或是引進(jìn)都有,在重要地方應(yīng)用也較多,由于價(jià)錢(qián)比普通彈子鎖較貴,早幾年應(yīng)用較少,現(xiàn)在越來(lái)越普及到平?;磥?lái)的發(fā)展也會(huì)越來(lái)越被大眾采用,由于它的功能、安全是彈子鎖無(wú)法相比的,發(fā)展前境也是非常大的。2系統(tǒng)整體方案設(shè)計(jì)2.1設(shè)計(jì)目標(biāo)本設(shè)計(jì)采用STC89C52單片機(jī)為主控芯片,結(jié)合外圍電路矩陣鍵盤(pán)、液晶顯示器LCD12864等部分組成。其中矩陣鍵盤(pán)用于輸入數(shù)字密碼和進(jìn)行各種功能的實(shí)現(xiàn)。由用戶通過(guò)連接單片機(jī)的矩陣鍵盤(pán)輸入密碼,后經(jīng)過(guò)單片機(jī)對(duì)用戶輸入的密碼與自己保存的密碼進(jìn)行對(duì)比,從而判斷密碼是否正確,然后控制引腳的高低電平傳到開(kāi)鎖電路或者報(bào)警電路控制開(kāi)鎖還是報(bào)警,組成的電子密碼鎖系統(tǒng),能夠?qū)崿F(xiàn):1.完全正確輸入6位密碼的前提下,有開(kāi)鎖提示;2.3次錯(cuò)誤輸入密碼情況下,蜂鳴器報(bào)警;3.用戶可以自行設(shè)定和修改密碼;系統(tǒng)整體設(shè)計(jì)框圖如圖2-1所示:主控芯片STC89C52顯示電路主控芯片STC89C52顯示電路輸入電路輸入電路復(fù)位電路復(fù)位電路晶振電路晶振電路輸出電路輸出電路圖2-1系統(tǒng)整體設(shè)計(jì)框圖2.2系統(tǒng)的基本方案2.2.1系統(tǒng)方案選擇采用以STC89C52為核心的單片機(jī)控制方案。利用單片機(jī)靈活的編程設(shè)計(jì)和豐富的I/O端口,及其控制的準(zhǔn)確性,實(shí)現(xiàn)基本的密碼鎖功能。其原理如圖2-2所示33×4鍵盤(pán)輸入STC89C52LCD12864顯示直流穩(wěn)壓電源報(bào)警圖2-2系統(tǒng)框圖2.2.2各模塊方案選擇單片機(jī)的選擇采用STC89C52單片機(jī),它是一種低功耗、高性能CMOS8位微控制器,具有8K在系統(tǒng)可編程Flash存儲(chǔ)器。在單芯片上,擁有靈巧的8位CPU和在系統(tǒng)可編程Flash,使得STC89C52為眾多嵌入式控制應(yīng)用系統(tǒng)提供高靈活、超有效的解決方案。鍵盤(pán)的選擇采用矩陣式鍵來(lái)控制,把按鍵按行列組成矩陣,在行列交點(diǎn)上都對(duì)應(yīng)有一個(gè)鍵,這樣使用的按鍵要少,為判定有無(wú)鍵被按下以及被按鍵的位置,這種稱為鍵掃描法。這樣雖然提高了編程難度,但是節(jié)約了單片機(jī)大量的I/O口,免去了上拉電阻為焊接帶來(lái)了方便,提高了整塊電路板的美觀度。顯示模塊的選擇液晶顯示采用LCD液晶顯示,顯示的位數(shù)多,由單片機(jī)驅(qū)動(dòng)。此方案有美觀、顯示清晰多樣的優(yōu)點(diǎn)。報(bào)警模塊的選擇采用蜂鳴器來(lái)報(bào)警,可以發(fā)出聲音報(bào)警且降低了成本。2.3主要元器件介紹2.3.1STC89C52的簡(jiǎn)介STC89C52是一種帶8K字節(jié)閃爍可編程可檫除只讀存儲(chǔ)器的低電壓,高性能COMOS8的微處理器,俗稱單片機(jī)。該器件采用ATMEL搞密度非易失存儲(chǔ)器制造技術(shù)制造,與工業(yè)標(biāo)準(zhǔn)的MCS-51指令集和輸出管腳相兼容。STC89C52具體介紹如下:①主電源引腳(2根)VCC(Pin40):電源輸入,接+5V電源GND(Pin20):接地線②外接晶振引腳(2根)XTAL1(Pin19):片內(nèi)振蕩電路的輸入端XTAL2(Pin20):片內(nèi)振蕩電路的輸出端③控制引腳(4根)RST/VPP(Pin9):復(fù)位引腳,引腳上出現(xiàn)2個(gè)機(jī)器周期的高電平將使單片機(jī)復(fù)位。ALE/PROG(Pin30):地址鎖存允許信號(hào)PSEN(Pin29):外部存儲(chǔ)器讀選通信號(hào)EA/VPP(Pin31):程序存儲(chǔ)器的內(nèi)外部選通,接低電平從外部程序存儲(chǔ)器讀指令,如果接高電平則從內(nèi)部程序存儲(chǔ)器讀指令。④可編程輸入/輸出引腳(32根)STC89C52單片機(jī)有4組8位的可編程I/O口,分別位P0、P1、P2、P3口,每個(gè)口有8位(8根引腳),共32根。P0口(P39~P32):8位雙向I/O口線,名稱為P0.0~P0.7P1口(P1~P8):8位準(zhǔn)雙向I/O口線,名稱為P1.0~P1.7P2口(P21~P28):8位準(zhǔn)雙向I/O口線,名稱為P2.0~P2.7P3口(P10~P17):8位準(zhǔn)雙向I/O口線,名稱為P3.0~PLCD12864的簡(jiǎn)介本設(shè)計(jì)所使用的是不帶字庫(kù)的LCD12864液晶顯示屏,因?yàn)槠淇梢栽趐roteus中仿真,便于設(shè)計(jì),其引腳表如2-3所示。表2-312864引腳3系統(tǒng)的硬件設(shè)計(jì)與實(shí)現(xiàn)3.1系統(tǒng)硬件概述本系統(tǒng)是通過(guò)鍵盤(pán)掃描模塊,既能夠顯示數(shù)據(jù)并且還能修改密碼,開(kāi)鎖密碼,具有強(qiáng)大的功能,通過(guò)鍵盤(pán)掃描模塊輸入到單片機(jī)控制系統(tǒng)STC89C52中。然后通過(guò)LCD顯示模塊來(lái)顯示我們所要有數(shù)據(jù),還有一個(gè)就是報(bào)警模塊,當(dāng)輸入的密碼相同時(shí),則顯示模塊的燈點(diǎn)亮,當(dāng)輸入的密碼是錯(cuò)誤時(shí),重新輸入,三次出錯(cuò)蜂鳴器響,發(fā)出報(bào)警。為了達(dá)到設(shè)定的功能,本裝置鍵盤(pán)掃描模塊、單片機(jī)控制模塊、LCD顯示模塊,報(bào)警模塊等4模塊組成。3.2主要單元電路的設(shè)計(jì)3.2.1鍵盤(pán)掃描模塊電路的設(shè)計(jì)如圖3-1所示,本模塊的作用是進(jìn)行鍵盤(pán)的掃描,首先判定有沒(méi)有鍵被按下,然后再判定被按鍵的位置,因?yàn)殒I盤(pán)矩陣有鍵被按下時(shí),被按鍵處的行線和列線被接通,使得開(kāi)關(guān)之間接通。當(dāng)掃描表明有按鍵被按下之后,緊接著應(yīng)是進(jìn)行去抖動(dòng)處理,一般我們采用的是軟件來(lái)去抖動(dòng),軟件方法則是采用時(shí)間延遲以躲過(guò)抖動(dòng),待行線上狀態(tài)穩(wěn)定之后,再進(jìn)行行狀態(tài)輸入。圖3-1鍵盤(pán)掃描電路圖3.2.2單片機(jī)控制模塊電路的設(shè)計(jì)單片機(jī)作為本裝置的核心器件,在系統(tǒng)中起到控制報(bào)警、以及LCD顯示的作用,其中采用的是STC89C52是標(biāo)準(zhǔn)的40引腳雙列直插式集成電路芯片,有4個(gè)八位的并行雙向I/O端口,分別記作P0、P1、P2、P3。第20引腳為接地端;第40引腳為電源端;第31引腳需要接高電位使單片機(jī)選用內(nèi)部程序存儲(chǔ)器;第18、19腳之間接上一個(gè)12MHz的晶振為單片機(jī)提供時(shí)鐘信號(hào);第9腳為復(fù)位腳,當(dāng)其接高電位時(shí),單片機(jī)停止工作。P1口接LCD控制引腳,P0口連接一LCD12864顯示屏數(shù)據(jù)輸入端,P3口與12個(gè)陣列式按鍵相連實(shí)現(xiàn)對(duì)鍵盤(pán)的掃描。如圖3-2所示。圖3-2主控電路圖3.2.3報(bào)警模塊電路的設(shè)計(jì)本模塊的作用是當(dāng)開(kāi)鎖按鈕被按下時(shí),如果LCD當(dāng)前顯示值相同,則紅燈點(diǎn)亮,當(dāng)輸入的數(shù)與密碼不同時(shí),則蜂鳴器立刻發(fā)出聲音報(bào)警。如圖3-3所示。圖3-3報(bào)警電路圖3.2LCD12864顯示模塊電路的設(shè)計(jì)本模塊主要用于顯示指示用戶密碼輸入要求。根據(jù)管腳要求連接電路,P0口接上拉電阻,并與LCD數(shù)據(jù)輸入端口連接,控制管腳與P1口連接。如圖3-4所示。圖3-4顯示模塊電路圖4系統(tǒng)的軟件設(shè)計(jì)與實(shí)現(xiàn)4.1KEIL軟件介紹Keil是美國(guó)Keil公司的C51編譯器,它被嵌入到了KeiluVision集成開(kāi)發(fā)環(huán)境中。Keil是目前最常用的編譯器,支持浮點(diǎn)等到類型,支持多維數(shù)組,能生成對(duì)應(yīng)的匯編代碼,能直接編譯匯編代碼程序和內(nèi)嵌多種工具,可以方便的鏈接,生成可執(zhí)行文件。KeiluVision2IDE是Keilsoftware公司的產(chǎn)品,它集項(xiàng)目管理、編譯工具、代碼編寫(xiě)工具、代碼調(diào)試以及完全仿真于一體,適合個(gè)人開(kāi)發(fā)或人數(shù)少、對(duì)開(kāi)發(fā)過(guò)程的管理還不成熟的開(kāi)發(fā)團(tuán)體。這一功能強(qiáng)大的軟件提供簡(jiǎn)易的開(kāi)發(fā)平臺(tái),可以讓開(kāi)發(fā)者在開(kāi)發(fā)過(guò)程中集中精力于項(xiàng)目本身,加快開(kāi)發(fā)速度。4.2系統(tǒng)程序設(shè)計(jì)流程圖4.2.1主程序軟件設(shè)計(jì)通過(guò)上述原理,已對(duì)密碼鎖整體運(yùn)行環(huán)境有了充分認(rèn)識(shí),繪制主程序和子程序流程圖,利用Keil軟件,對(duì)單片機(jī)進(jìn)行編程,如圖4-1為主程序功能流程圖:4-1主程序功能流程圖4.2.2按鍵軟件設(shè)計(jì)如圖4-2為按鍵功能流程圖,在按鍵當(dāng)中,有與輸入、開(kāi)鎖、清除、設(shè)置、確認(rèn)的程序相對(duì)應(yīng)的按鍵,并按順序與輸入的數(shù)相比較,當(dāng)輸入正確時(shí),進(jìn)入密碼程序,錯(cuò)誤時(shí)進(jìn)行清除,輸入兩次新密碼正確時(shí),可進(jìn)行重新設(shè)置密碼,最后確認(rèn)程序。4-2按鍵功能流程圖4.2.3密碼設(shè)置軟件設(shè)計(jì)如圖4-3為密碼設(shè)置流程圖,開(kāi)始按下設(shè)置鍵,輸入舊密碼,如果錯(cuò)誤累計(jì)三次,進(jìn)行報(bào)警程序。如輸入正確,可以修改密碼,確認(rèn)后再次輸入新密碼,如兩次輸入一樣,則更成功。如果兩次輸入的新密碼不一樣,則修改密碼失敗,重新返回設(shè)置新密碼。4-3密碼設(shè)置程序流程圖4.2.4開(kāi)鎖軟件設(shè)計(jì)如圖4-4為開(kāi)鎖流程圖,開(kāi)始時(shí)按開(kāi)鎖鍵,輸入密碼,如果輸入正確,則開(kāi)鎖成功。如果輸入錯(cuò)誤累計(jì)達(dá)到三次,則執(zhí)行報(bào)警程序。4-4開(kāi)鎖程序流程圖5系統(tǒng)仿真設(shè)計(jì)5.1Proteus軟件介紹Proteus軟件是英國(guó)Labcenterelectronics公司出版的EDA工具軟件。它不僅具有其它EDA工具軟件的仿真功能,還能仿真單片機(jī)及外圍器件。它是目前最好的仿真單片機(jī)及外圍器件的工具。Proteus是世界上著名的EDA工具(仿真軟件),從原理圖布圖、代碼調(diào)試到單片機(jī)與外圍電路協(xié)同仿真,一鍵切換到PCB設(shè)計(jì),真正實(shí)現(xiàn)了從概念到產(chǎn)品的完整設(shè)計(jì)。在PROTEUS繪制好原理圖后,調(diào)入已編譯好的目標(biāo)代碼文件:*.HEX,可以在PROTEUS的原理圖中看到模擬的實(shí)物運(yùn)行狀態(tài)和過(guò)程。PROTEUS不僅可將許多單片機(jī)實(shí)例功能形象化,也可將許多單片機(jī)實(shí)例運(yùn)行過(guò)程形象化。使用Proteus軟件進(jìn)行單片機(jī)系統(tǒng)仿真設(shè)計(jì),是虛擬仿真技術(shù)和計(jì)算機(jī)多媒體技術(shù)相結(jié)合的綜合運(yùn)用,有利于培養(yǎng)學(xué)生的電路設(shè)計(jì)能力及仿真軟件的操作能力;在單片機(jī)課程設(shè)計(jì)和全國(guó)大學(xué)生電子設(shè)計(jì)競(jìng)賽中,我們使用Proteus開(kāi)發(fā)環(huán)境對(duì)學(xué)生進(jìn)行培訓(xùn),在不需要硬件投入的條件下,學(xué)生普遍反映,對(duì)單片機(jī)的學(xué)習(xí)比單純學(xué)習(xí)書(shū)本知識(shí)更容易接受,更容易提高。實(shí)踐證明,在使用Proteus進(jìn)行系統(tǒng)仿真開(kāi)發(fā)成功之后再進(jìn)行實(shí)際制作,能極大提高單片機(jī)系統(tǒng)設(shè)計(jì)效率。因此,Proteus有較高的推廣利用價(jià)值。5.2Proteus仿真圖圖5-1為輸入密碼界面圖,圖5-2為選擇界面,實(shí)現(xiàn)開(kāi)鎖與修改密碼的選擇。圖5-1輸入密碼界面圖圖5-2選擇界面圖5.3硬件調(diào)試硬件調(diào)試主要是測(cè)試各硬件部分能否完成設(shè)計(jì)功能。在焊接的過(guò)程中,每接一根線都用萬(wàn)用表測(cè)試是否短路或開(kāi)路。這樣焊接完了之后,就不必懷疑線路不通的問(wèn)題了,由于線路很繁瑣也免去了大量排查的工作。最初焊接最小系統(tǒng),查看二極管能否正常閃爍,以此判斷單片機(jī)是否正常工作。整體電路焊接完后,通電測(cè)試所有硬件芯片的輸入輸出電壓是否在設(shè)計(jì)要求的范圍內(nèi),判斷單片機(jī)的工作與否。5.4調(diào)試結(jié)果在調(diào)試中出現(xiàn)的很多問(wèn)題,開(kāi)始顯示屏不顯示,經(jīng)排查是一處地線沒(méi)連接,導(dǎo)致顯示屏供不上電。連接后顯示屏正常亮了,但是顯示不出想要的結(jié)果,調(diào)節(jié)可變電阻,改變背光度,依然不顯示。經(jīng)高玉芹,田傳耕老師的指導(dǎo),我們知道是程序的問(wèn)題。于是我們修改了程序,并最終調(diào)試出想要的效果。6結(jié)論首先,感謝高玉芹老師給我們這次機(jī)會(huì),讓我們做硬件。因?yàn)橐佳校鞠氩蛔龅?,但是難得有一次機(jī)會(huì)來(lái)讓我們得到鍛煉,我們很珍惜。這份課程設(shè)計(jì),我們嚴(yán)格按照畢業(yè)論文的標(biāo)準(zhǔn)來(lái)。程序,我們自己來(lái)研究,探討,參考一些學(xué)長(zhǎng)做的項(xiàng)目中相關(guān)程序。在網(wǎng)上搜集資料時(shí),發(fā)現(xiàn)很多關(guān)于LCD1602做的密碼鎖,LCD12864做的少之又少,所以我們想挑戰(zhàn)一下,即使失敗,但當(dāng)中的過(guò)程卻是無(wú)價(jià)的。在做這個(gè)設(shè)計(jì)的時(shí)候是信心滿滿的,查了網(wǎng)絡(luò)資料,也到圖書(shū)館搜集了資料,結(jié)合生活中對(duì)密碼鎖的功能特性要求,我們?cè)O(shè)計(jì)出一套電子密碼鎖系統(tǒng)的主要硬件結(jié)構(gòu)和軟件結(jié)構(gòu),基本完成了課題的要求。不過(guò)由于了解的專業(yè)知識(shí)尚淺,對(duì)課題的研究經(jīng)驗(yàn)的不足,使得在技術(shù)的解決與運(yùn)用上顯得粗糙了一些,特別是功能按鍵的設(shè)定。但因?yàn)槲覀兊乃接邢?,此電路中也存在大量的?wèn)題。譬如說(shuō)電路的密碼不能遺忘,一旦遺忘,就很難打開(kāi)等,所以很遺憾!回顧起此次單片機(jī)課程設(shè)計(jì),至今我仍感慨頗多。的確,從選題到定稿,從理論到實(shí)踐,在整整兩星期的日子里,我們焊接了4塊板子,一遍遍的排查軟硬件的錯(cuò)誤,可以說(shuō)是達(dá)到了廢寢忘食的地步。雖然是苦多于甜,但是可以學(xué)到很多很多的的東西,同時(shí)不僅可以鞏固了以前所學(xué)過(guò)的知識(shí),而且學(xué)到了很多在書(shū)本上所沒(méi)有學(xué)到過(guò)的知識(shí)。通過(guò)這次課程設(shè)計(jì)使我懂得了理論與實(shí)際相結(jié)合是很重要的,只有理論知識(shí)是遠(yuǎn)遠(yuǎn)不夠的,只有把所學(xué)的理論知識(shí)與實(shí)踐相結(jié)合起來(lái),從理論中得出結(jié)論,才能真正為社會(huì)服務(wù),從而提高自己的實(shí)際動(dòng)手能力和獨(dú)立思考的能力。在設(shè)計(jì)的過(guò)程中遇到問(wèn)題,可以說(shuō)得是困難重重,這畢竟第一次做的,難免會(huì)遇到過(guò)各種各樣的問(wèn)題,同時(shí)在設(shè)計(jì)的過(guò)程中發(fā)現(xiàn)了自己的不足之處,對(duì)以前所學(xué)過(guò)的知識(shí)理解得不夠深刻,掌握得不夠牢固,對(duì)單片機(jī)C語(yǔ)言掌握得不好,通過(guò)這次課程設(shè)計(jì)之后,一定把以前所學(xué)過(guò)的知識(shí)重新溫故。徐州工程學(xué)院?jiǎn)纹瑱C(jī)原理及應(yīng)用課程設(shè)計(jì)PAGE44參考文獻(xiàn)[1]高玉芹.單片機(jī)原理及應(yīng)用及C51編程技術(shù).北京:機(jī)械工業(yè)出版社,2011.6[2]趙文博,劉文濤.單片機(jī)語(yǔ)言C51程序設(shè)計(jì)[M].北京:人民郵電出版社,2005,10.[3]孫育才.MCS-51系列單片微型計(jì)算機(jī)及其應(yīng)用[M].東南大學(xué)出版社,2004,6.[4]沈紅衛(wèi).單片機(jī)應(yīng)用系統(tǒng)設(shè)計(jì)實(shí)力與分析[M].北京:北京航空航天大學(xué)出版社,2003.[5]徐愛(ài)鈞,彭秀華.單片機(jī)高級(jí)語(yǔ)言C51應(yīng)用程序設(shè)計(jì)[M].北京航空航天大學(xué)出版社,2006.[6]曾一江.單片微機(jī)原理與接口技術(shù)[M].北京:科技出版社,2009,12.[7]康華光.電子技術(shù)基礎(chǔ)(模擬部分)[M].北京:高等教育出版社,2004,4.[8]江曉安,董秀峰.模擬電子技術(shù)[M].西安電子科技大學(xué)出版社,2001.10[9]戴佳,苗龍,陳斌.51單片機(jī)應(yīng)用系統(tǒng)開(kāi)發(fā)典型實(shí)例[M].中國(guó)電力出版社,2005.9[10]榮貴.電子制作[M].科學(xué)技術(shù)文獻(xiàn)出版社,2003[11]劉建清.輕松玩轉(zhuǎn)51單片機(jī):魔法入門(mén)·實(shí)例解析·開(kāi)發(fā)揭秘全攻略[M].北京航空航天大學(xué)出版社,2011附錄附錄1硬件實(shí)物圖附錄2C語(yǔ)言源程序主函數(shù): #include<reg51.h>#include<12864.h>#include<keypad.h>#include<chu.h>#defineucharunsignedchar#defineuintunsignedintsbitLED1=P1^5;sbitLED2=P1^6;sbitINIT=P2^2;sbitSOUND=P1^7;ucharidatakey[6]={0,0,0,0,0,0};ucharidataiic[6]={0,1,2,3,4,5};voidpress(uchar*s){ uchardat;//**************************************************P3=0xf0; //保存第一位密碼 while(P3==0xf0);dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,16); } s++; //************************************************** P3=0xf0; //保存第二位密碼 while(P3==0xf0); dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,24); } s++; //************************************************** P3=0xf0; //保存第三位密碼 while(P3==0xf0); dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,32); } s++; //************************************************** P3=0xf0; //保存第四位密碼 while(P3==0xf0); dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,40); } s++; //************************************************** P3=0xf0; //保存第五位密碼 while(P3==0xf0); dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,48); } s++; //************************************************** P3=0xf0; //保存第六位密碼 while(P3==0xf0); dat=key_scan(); if((dat!=0x0a)&&(dat!=0x0b)){*s=dat; Left(); star_12864(star,0x05,56); }//************************************************** do{P3=0xf0; //鍵入Enter鍵盤(pán)繼續(xù)執(zhí)行下面語(yǔ)句,否則等待 while(P3==0xf0); dat=key_scan(); }while(dat!=0x0b);}voidDelay10ms(void) //延時(shí)10ms{ uinti,j,k; for(i=5;i>0;i--) for(j=4;j>0;j--) for(k=248;k>0;k--);}voidmain(){uchardat;uchari=0,j=0,k;ucharx; LED1=1; LED2=1; SOUND=0; INIT=1;if(INIT==0) //密碼初始化{ x=SendB(iic,0x50,6); Delay10ms();} //首先從IIC器件中讀出密碼以供下面輸入密碼進(jìn)行比較x=ReadB(iic,0x50,6);Init_12864(); for(i=0;i<150;i++){Delay10ms();}//**********************************若密碼不正確,循環(huán)執(zhí)行do{}while()********************************************do{ LED1=1; System(); //顯示:"請(qǐng)輸入密碼"字幕 press(key); if((key[0]==iic[0])&&(key[1]==iic[1])&&(key[2]==iic[2])&&(key[3]==iic[3])&&(key[4]==iic[4])&&(key[5]==iic[5]))//密碼比較,若密碼正確責(zé)進(jìn)入系統(tǒng),若密碼不正確則顯示密碼錯(cuò)誤,重新輸入密碼{ true(); do { P3=0xf0; //鍵入1或2繼續(xù)執(zhí)行下面語(yǔ)句,否則等待 while(P3==0xf0); dat=key_scan(); }while(dat!=0x01&&dat!=0x02); if(dat==1) //開(kāi)鎖 { LED1=0; unlock(); for(i=0;i<100;i++){Delay10ms();} continue; } if(dat==2) //修改密碼 { do{ System(); press(key); again(); press(iic); if((key[0]==iic[0])&&(key[1]==iic[1])&&(key[2]==iic[2])&&(key[3]==iic[3])&&(key[4]==iic[4])&&(key[5]==iic[5])) { succeed(); //修改密碼成功 for(i=0;i<100;i++){Delay10ms();} Delay10ms(); x=SendB(iic,0x50,6); Delay10ms(); x=ReadB(iic,0x50,6);break; } else //修改密碼不成功,重新修改 { repeat(); for(i=0;i<100;i++){Delay10ms();} } }while(1); } } else //密碼不正確,重新輸入密碼 { j++; if(j==3) { for(i=0;i<8;i++) { LED2=0; for(k=0;k<5;k++){Delay10ms();} LED2=1; for(k=0;k<5;k++){Delay10ms();} } j=0; } error(); for(i=0;i<50;i++){Delay10ms();} }}while(1); }鍵盤(pán)函數(shù): #ifndef_keypad_h_#define_keypad_h_#include<reg51.h>#include<absacc.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintucharidatacom1,com2;ucharkey_scan(){uchartemp;ucharcom;P3=0xf0;if(P3!=0xf0) {com1=P3;P3=0x0f;com2=P3;} P3=0xf0;while(P3!=0xf0); temp=com1|com2; if(temp==0xee)com=0x01; if(temp==0xed)com=0x02; if(temp==0xeb)com=0x03; if(temp==0xde)com=0x04; if(temp==0xdd)com=0x05; if(temp==0xdb)com=0x06; if(temp==0xbe)com=0x07; if(temp==0xbd)com=0x08; if(temp==0xbb)com=0x09; if(temp==0x7e)com=0x0a; //10為鍵值,其代碼功能為清除 if(temp==0x7d)com=0x00; if(temp==0x7b)com=0x0b; //其代碼功能為輸入密碼結(jié)束并確認(rèn),即開(kāi)鎖 return(com);}#endif12864顯示函數(shù):#ifndef_12864_h_#define_12864_h_#include<reg51.h>#include<absacc.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedint#definePORTP0ucharcodeNum[]={ //32×32字節(jié)的漢字取模,一個(gè)漢字72字節(jié)0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 720x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 1440x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 2160x00,0x00,0x00,0x00,0x10,0x00,0x00,0x08,0x00,0x00,0x46,0x00,0x00,0x47,0x00,0xC0,0x45,0x00,0xF0,0x64,0x1E,0x7E,0xFE,0x1F,0x4E,0x26,0x0C,0x60,0x32,0x06,0x60,0x32,0x42,0x00,0x00,0x40,0x30,0x86,0x21,0x70,0xFF,0x33,0x20,0x03,0x18,0x03,0xD9,0x0F,0xFF,0xF9,0x03,0x06,0x09,0x04,0x20,0x01,0x0C,0xB0,0xFF,0x1B,0x1C,0xFF,0x39,0x0C,0x00,0x70,0x08,0x00,0x00,0x00,0x00,0x00,//鎖 2880x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x10,0x00,0x08,0x10,0x10,0x0C,0x08,0x10,0x0C,0x0E,0x10,0x84,0x03,0xF8,0xFF,0x01,0xF8,0x3F,0x00,0x18,0x06,0x00,0x18,0x06,0x00,0x1C,0x06,0x00,0xFC,0xFF,0x07,0xFC,0xFF,0xFF,0x0C,0x02,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x02,0x00,0x00,0x00,0x00,//開(kāi) 360};ucharcodeTab[]={ //16×16字節(jié)的漢字取模,一個(gè)漢字32個(gè)字節(jié)0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//+320x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//+640x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00,//電+960x80,0x80,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//子+1280x10,0x4C,0x24,0x04,0xF4,0x84,0x4D,0x56,0x24,0x24,0x14,0x84,0x24,0x54,0x0C,0x00,0x00,0x01,0xFD,0x41,0x40,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0xFC,0x00,0x00,0x00,//密+1600x02,0x82,0xF2,0x4E,0x43,0xE2,0x42,0xFA,0x02,0x02,0x02,0xFF,0x02,0x80,0x00,0x00,0x01,0x00,0x7F,0x20,0x20,0x7F,0x08,0x09,0x09,0x09,0x0D,0x49,0x81,0x7F,0x01,0x00,//碼+1920x80,0x40,0x70,0xCF,0x48,0x48,0x00,0xE2,0x2C,0x20,0xBF,0x20,0x28,0xF6,0x20,0x00,0x00,0x02,0x02,0x7F,0x22,0x92,0x80,0x4F,0x40,0x20,0x1F,0x20,0x20,0x4F,0x80,0x00,//鎖 +2240x20,0x22,0xEC,0x00,0x20,0x22,0xAA,0xAA,0xAA,0xBF,0xAA,0xAA,0xEB,0xA2,0x20,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x0A,0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x00,//請(qǐng) 2560x88,0x68,0x1F,0xC8,0x0C,0x28,0x90,0xA8,0xA6,0xA1,0x26,0x28,0x10,0xB0,0x10,0x00,0x09,0x09,0x05,0xFF,0x05,0x00,0xFF,0x0A,0x8A,0xFF,0x00,0x1F,0x80,0xFF,0x00,0x00,//輸 2880x00,0x00,0x00,0x00,0x00,0x01,0xE2,0x1C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0xC0,0x40,0x00,//入 3200x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//:冒號(hào)3520x80,0x40,0x70,0xCF,0x48,0x48,0x48,0x48,0x7F,0x48,0x48,0x7F,0xC8,0x68,0x40,0x00,0x00,0x02,0x02,0x7F,0x22,0x12,0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x01,0x00,0x00,//錯(cuò) 3840x40,0x42,0xC4,0x0C,0x00,0x40,0x5E,0x52,0x52,0xD2,0x52,0x52,0x5F,0x42,0x00,0x00,0x00,0x00,0x7F,0x20,0x12,0x82,0x42,0x22,0x1A,0x07,0x1A,0x22,0x42,0xC3,0x42,0x00,//誤 4160x08,0x08,0x0A,0xEA,0xAA,0xAA,0xAA,0xFE,0xAA,0xAA,0xA9,0xF9,0x29,0x0C,0x08,0x00,0x40,0x40,0x48,0x4B,0x4A,0x4A,0x4A,0x7F,0x4A,0x4A,0x4A,0x4B,0x48,0x60,0x40,0x00,//重 4480x40,0x44,0x54,0x65,0xC6,0x64,0xD6,0x44,0x40,0xFC,0x44,0x42,0xC3,0x62,0x40,0x00,0x20,0x11,0x49,0x81,0x7F,0x01,0x05,0x29,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00,//新 4800x40,0x42,0x44,0xCC,0x00,0x60,0x5E,0x48,0xC8,0x7F,0xC8,0x48,0x4C,0x68,0x40,0x00,0x00,0x40,0x20,0x1F,0x20,0x60,0x90,0x8C,0x83,0x80,0x8F,0x90,0x90,0xD0,0x5C,0x00,//選 5120x10,0x10,0x10,0xFF,0x90,0x50,0x82,0x46,0x2A,0x92,0x2A,0x46,0x82,0x80,0x80,0x00,0x02,0x42,0x81,0x7F,0x00,0x09,0x08,0x09,0x09,0xFF,0x09,0x09,0x0C,0x09,0x00,0x00,//擇 5440x80,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x82,0x83,0xC2,0x80,0x00,0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,//開(kāi) 5760x40,0x20,0xF8,0x07,0xF0,0xA0,0x90,0x4F,0x54,0x24,0xD4,0x4C,0x84,0x80,0x80,0x00,0x00,0x00,0xFF,0x00,0x0F,0x80,0x92,0x52,0x49,0x25,0x24,0x12,0x08,0x00,0x00,0x00,//修 6080x04,0xC4,0x44,0x44,0x44,0xFE,0x44,0x20,0xDF,0x10,0x10,0x10,0xF0,0x18,0x10,0x00,0x00,0x7F,0x20,0x20,0x10,0x90,0x80,0x40,0x21,0x16,0x08,0x16,0x61,0xC0,0x40,0x00,//改 6400x00,0x02,0x02,0xF2,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0xFA,0x13,0x02,0x00,0x00,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x07,0x04,0x44,0x84,0x7F,0x04,0x06,0x04,0x00,//再 6720x00,0x02,0x04,0x8C,0x40,0x00,0x20,0x18,0x17,0xD0,0x10,0x50,0x38,0x10,0x00,0x00,0x02,0x02,0xFF,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x0C,0x10,0x60,0xC0,0x40,0x00,//次 7040x04,0x84,0xE4,0x9C,0x84,0xC6,0x24,0xF0,0x28,0x27,0xF4,0x2C,0x24,0xF0,0x20,0x00,0x01,0x00,0x7F,0x20,0x20,0xBF,0x40,0x3F,0x09,0x09,0x7F,0x09,0x89,0xFF,0x00,0x00,//確 7360x40,0x42,0x44,0xCC,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x90,0x48,0x30,0x0E,0x01,0x00,0x01,0x0E,0x30,0xC0,0x40,0x00,//認(rèn) 7680x00,0x00,0xF8,0x88,0x88,0x88,0x88,0x08,0x7F,0x88,0x0A,0x0C,0x08,0xC8,0x00,0x00,0x40,0x20,0x1F,0x00,0x08,0x10,0x0F,0x40,0x20,0x13,0x1C,0x24,0x43,0x80,0xF0,0x00,//成 8000x08,0x08,0x08,0xF8,0x0C,0x28,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0xF0,0x20,0x00,0x08,0x18,0x08,0x0F,0x84,0x44,0x20,0x1C,0x03,0x20,0x40,0x80,0x40,0x3F,0x00,0x00,//功 8320x00,0x00,0x00,0x00,0x00,0x00,0x08,0xF8,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x3F,0x20,0x00,0x00,0x00,0x00,0x00,0x00,//1 8640x00,0x00,0x00,0x00,0x30,0x38,0x0C,0x04,0x04,0x0C,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x30,0x38,0x2C,0x26,0x23,0x21,0x38,0x00,0x00,0x00,0x00,//2 8960x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9280x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9600x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//992};ucharcodestar[]={0x00,0x08,0x2A,0x1C,0x1C,0x2A,0x08,0x00,};//輸入密碼時(shí)顯示的符號(hào),而不顯示真正的密碼sbitCS1=P1^0;sbitCS2=P1^1;sbitRS=P1^2;sbitRW=P1^3;sbitE=P1^4;sbitbflag=P0^7;//**************************************************************************驅(qū)動(dòng)函數(shù)voidLeft(){CS1=0;CS2=1;}voidRight(){CS1=1;CS2=0;}voidBusy_12864(){ do{E=0; RS=0; RW=1; PORT=0xff; E=1; E=0;}while(bflag);}voidWreg(ucharc){ Busy_12864(); RS=0; RW=0; PORT=c; E=1; E=0;}voidWdata(ucharc){ Busy_12864(); RS=1; RW=0; PORT=c; E=1; E=0;}voidPagefirst(ucharc){ uchari; i=c; c=i|0xb8; Busy_12864(); Wreg(c);}voidLinefirst(ucharc){ uchari; i=c; c=i|0x40; Busy_12864(); Wreg(c);}//********************************************************************voidReady_12864() //清屏函數(shù){uinti,j;Left();Wreg(0x3f);Right();Wreg(0x3f);Left();for(i=0;i<8;i++){ Pagefirst(i); Linefirst(0x00); for(j=0;j<64;j++) { Wdata(0x00); }}Right();for(i=0;i<8;i++){ Pagefirst(i); Linefirst(0x00); for(j=0;j<64;j++) { Wdata(0x00); } }}//**********************************************************************************voidDisplay(uchar*s,ucharpage,ucharline) //16×16的漢字顯示函數(shù),下半排列取模{ uchari,j; Pagefirst(page); Linefirst(line); for(i=0;i<16;i++) {Wdata(*s); s++; } Pagefirst(page+1); Linefirst(line); for(j=0;j<16;j++) {Wdata(*s); s++; }}//********************************************************************************voidDisplay_32(uchar*s,ucharpage,ucharline) //24×24的漢字顯示函數(shù),下上排列取模{uchari,j;for(i=0;i<24;i++){for(j=0;j<3;j++) { Pagefirst(page+j); Linefirst(line+i); Wdata(*s); s++; } }}//*******************************************************************************voidstar_12864(uchar*s,ucharpage,ucharline) //com=10,18,26,,.在顯示屏上寫(xiě)入星號(hào),代表密碼{uchari;Pagefirst(page);Linefirst(line);for(i=0;i<8;i++){Wdata(*s);s++;}}voidpoint_12864(ucharpage,ucharline) //在顯示屏上畫(huà)一條線{uchari;Pagefirst(page); Linefirst(line); for(i=0;i<56;i++) { Wdata(0x1e); }}voidInit_12864() //初始化,顯示實(shí)驗(yàn)名稱{ Ready_12864(); // Left(); Display_32(Num,0x00,16); Display_32(Num+72,0x00,40); point_12864(0x03,8); Display(Tab,0x04,16); Display(Tab+32,0x04,32); Display(Tab+64,0x04,48); Display(Tab+96,0x06,16); Display(Tab+128,0x06,32); Display(Tab+160,0x06,48); Right(); Display_32(Num+144,0x00,0); Display_32(Num+216,0x00,24); point_12864(0x03,0); Display(Tab+352,0x04,0); Display(Tab+928,0x04,4); Display(Tab+960,0x04,18); Display(Tab+992,0x04,30); Display(Tab+192,0x06,0); Display(Tab+224,0x06,16);}voidSystem() //在顯示屏上顯示初始字幕:請(qǐng)輸入密碼{Ready_12864();Left();Display(Tab+256,0x02,16);Display(Tab+288,0x02,32);Display(Tab+320,0x02,48);point_12864(0x04,8);Right();Display(Tab+160,0x02,0);Display(Tab+192,0x02,16);Display(Tab+352,0x02,32);point_12864(0x04,0);}voiderror() //密碼錯(cuò)誤,重新輸入密碼{Ready_12864();Left();Display(Tab+160,0x02,32);Display(Tab+192,0x02,48);Display(Tab+448,0x04,16);Display(Tab+480,0x04,32);Display(Tab+288,0x04,48);Right();Display(Tab+384,0x02,0);Display(Tab+416,0x02,16);Display(Tab+320,0x04,0);Display(Tab+160,0x04,16);Display(Tab+192,0x04,32);}voidtrue() //請(qǐng)選擇1開(kāi)鎖2修改密碼{Ready_12864();Left();Display(Tab+256,0x00,0);Display(Tab+512,0x00,16);Display(Tab+544,0x00,32);Display(Tab+352,0x00,48);Display(Tab+864,0x03,0);Display(Tab+576,0x03,16);Display(Tab+224,0x03,32);Display(Tab+896,0x06,0);Display(Tab+608,0x06,16);Display(Tab+640,0x06,32);Display(Tab+160,0x06,48);Right();Display(Tab+192,0x06,0);}voidunlock() //開(kāi)鎖畫(huà)面{Ready_12864();Left();Display_32(Num+288,0x03,20);point_12864(0x02,8);point_12864(0x06,8);Right();Display_32(Num+360,0x03,20);point_12864(0x02,0);point_12864(0x06,0);}voidagain() //請(qǐng)?jiān)俅屋斎朊艽a{Ready_12864();Left();Display(Tab+256,0x00,0);Display(Tab+672,0x00,16);Display(Tab+704,0x00,32);Display(Tab+288,0x00,48);Right();Display(Tab+320,0x00,0);Display(Tab+160,0x00,16);Display(Tab+192,0x00,32);Display(Tab+352,0x00,48);}voidrepeat() //密碼確認(rèn)錯(cuò)

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論