数字密码锁的设计源代码_第1页
数字密码锁的设计源代码_第2页
数字密码锁的设计源代码_第3页
数字密码锁的设计源代码_第4页
数字密码锁的设计源代码_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

1、电子与信息工程学院本 科 毕 业 论 文论文题目 数字密码锁的设计 学生姓名 学 号 专 业 电子信息科学与技术 班 级 电信 指导教师 2010年5月摘 要基于atmega88v设计的数字密码锁是以atmega88v为核心控制电路,配以电源电路、复位电路、指示电路、报警电路、键盘电路等外围电路,实现对密码的输入、识别、修改、存储及输入密码错误时报警等功能。该系统中,atmega88v是输入和输出的联系部件,它通过读取从键盘输入的数据并对存储在单片机中的密码进行识别比较,判断密码是否输入正确,并作出相应的决定,指示报警器是否发出嗡鸣声以及发光二极管是否闪烁。这种密码锁以其安全性高、成本低、易操

2、作等优点受到越来越多人的欢迎。关键词:密码锁;atmega88v;键盘;lcd显示abstractthe core control circuit of digital code lock designed based on atmega88v is atmega88v,and together with the power circuit, reset circuit, indicating circuit, alarm circuit, keyboard and other peripheral circuits circuit it can realize the function of

3、 input, identification, modification, storage of the password, and the alarm when inputting the wrong password. in the system, atmega88v is the link of input and output components, it can estimate whether the input password is right by identifying and comparing the data reading from the keyboard and

4、 the password stored in the microcontroller, and make the appropriate decision that whether the indicating alarm audible hum and the light diode blinking. because of its high security, low cost, easy operation, etc, this digital code lock is more and more popular. key words: digital code lock; atmeg

5、a88v; keyboard; lcd display目 录1.绪 论12. 课题设计方案32.1 整体方案选择32.2 控制器的选择52.2.1 51系列单片机概述52.2.2 pic系列52.2.3 avr系列63.系统的主要器件93.1 atmega88v单片机简介93.2 液晶显示模块0802114.硬件设计154.1 单片机的最小系统154.2 键盘电路164.3 显示电路174.4 报警电路185.软件设计196.调试216.1 软件调试216.2 硬件调试217. 结论与展望23参考文献25附录a(原理图):27附录b(pcb图):28附录c(实物图):29附录d(main.c)

6、:30 参考文献1 朱璇,唐晓茜,殷建军基于单片机智能加密电子密码锁设计j轻工机械,2009.82 孟祥忠.数字电子密码锁的设计d.大连理工,2007.63 刘潇婷.基于fpga的红外遥控电子密码锁的实现d.大连海事大学,2008.34 邱燕,邓鹏戈数字电子密码锁j现代电子技术,2010.75 王红航,张华斌.电子密码锁的eda设计与实现j.电子元器件应用,2009.66 陈华丽,何颜平.基于vhdl的数字密码锁设计j.研究与开发,2008.87 罗维,葛亦斌,邱烨,盛蒙蒙.基于at89s52电子密码锁系统的设计j.数字技术与应用,2009.78 张毅刚.新编mcs-51单片机应用设计m.哈尔

7、滨:哈尔滨工业大学出版社,2003.69 张培仁.基于c语言编程mcs-51单片机原理与应用m.北京:清华大学出版社,2002.1010 耿德根avr单片机将领导八位单片机新潮流8051将终成为历史j电子质量,2001,8.11 陈再清pic单片机、51单片机和avr单片机的对比分析j.电子质量,2006.8.12 吴双力,崔剑,王伯岭.avr-gcc与avr单片机c语言开发m.北京:北京航空航天大学出版社出版,20041013 李广第,朱月秀.单片机基础(第3板)m北京:北京航空航天大学出版社,2007.6.14 胡汉才.高档avr单片机原理及其应用m.北京:清华大学出版社,2008.315

8、 mega88 atmel datasheet16 江海波,王卓然,耿德根.深入浅出avr单片机:从atmega48/88/168开始m北京:中国电力出版社,2008.617 刘兰香,张秋生.atmega128单片机应用与开发实例m.北京:机械工业出版社,2006.4.18 李宏,张家田.液晶显示器件应用技术m.北京:机械工业出版社,2004.219 李广第,朱月秀.单片机基础(第3板)m北京:北京航空航天大学出版社,2007.6.20 金春林,邱慧芳.avr系列单片机c语言编程与应用实例m.北京:清华大学出版社,2003.621 楼然苗,李光飞.单片机课程设计指导m.北京:北京航空航天大学出

9、版社,2007.722 李捷,陈典涛,陈建华.一种基于单片机的电子密码锁的设计j农机化研究,2004.923 徐玮.51单片机综合学习系统1602字符型液晶显示篇j电子制作,2008.824 first chip empress the system eda/ic of the electronics engineering designm25 shucheng zhu,zhenwang,tianwei zhuo,linzhong zhu. an intelligent robot based on sound source localization and ultrasound distan

10、ce detectionj. department of electrical and computer engineering,the hong kong university of science and technology,hk;department of computer control system,shajiao b power smfion ltd26 陈建林,赵立红.基于proteus的数字密码锁的仿真设计j.机械工程与自动化,2009.1027 李智辉,李浩泷,白宇龙.基于51单片机密码锁的proteus仿真设计j.电脑知识与技术,2009.6附 录附录a(原理图):附录b

11、(pcb图):附录c(实物图):附录d(main.c):#include iom88v.h#include macros.h#include head.hvoid initial(void);void delay(unsigned int);void lcdinit(void); /lcd初始化void lcdbusytest(void);/lcd判忙子程序void lcdwrite(void); /lcd写入void lcdoutput(unsigned char message); /lcd写程序void memoryread(void);void memorywrite(void);un

12、signed char read_eeprom(unsigned int addr);void write_eeprom(unsigned int addr, unsigned char data);void check(void);/-中断子程序开始 -#pragma interrupt_handler pcint1_isr:iv_pcint1void pcint1_isr(void) unsigned char i,j = 0;keyboard = pinc&0x3f;for(i=1;i=6;i+)j = keyboard&bit(i-1); if(j=0)keytest13 = i +

13、0x30;/用于做键盘测试switch(i) case 1: number = 3; break; case 2: number = 6; break; case 3: number = 2; break; case 4: number = 5; break;case 5: number = 1; break; case 6: number = 4; break; pcifr |= bit(pcif1); /再次将标志位清除,防止抖动/-中断子程序 结束-/-eeprom读写程序 开始-void write_eeprom(unsigned int addr, unsigned char dat

14、a) while(eecr&(1eewe); eear = addr; eedr = data; cli(); eecr |= (1eemwe); eecr |= (1eewe); sei(); unsigned char read_eeprom(unsigned int addr) while(eecr&(1eewe); eear = addr; eecr |= (1eere); return eedr;/-eeprom读写程序 结束-/-eeprom数据存取 开始-void memoryread(void) password0 = read_eeprom(0x01); password1

15、= read_eeprom(0x02); password2 = read_eeprom(0x03); password3 = read_eeprom(0x04); password4 = read_eeprom(0x05); password5 = read_eeprom(0x06); password6 = read_eeprom(0x07); password7 = read_eeprom(0x08);void memorywrite(void) write_eeprom(0x01,setpassword8); write_eeprom(0x02,setpassword9); write

16、_eeprom(0x03,setpassword10); write_eeprom(0x04,setpassword11); write_eeprom(0x05,setpassword12); write_eeprom(0x06,setpassword13); write_eeprom(0x07,setpassword14); write_eeprom(0x08,setpassword15); write_eeprom(0x10,0x88);/-eeprom数据存取 结束-/-延时子程序 开始-void delay(unsigned int delaytime) unsigned int te

17、mp1=0;/*临时变量*/ unsigned int temp2=0;/*临时变量*/ for(temp1=1;temp1=delaytime;temp1+) for (temp2=1;temp2 0;i-) lcdwrite();portb = 0x38; /数据总线8位,显示行数2行,字符5*7点阵lcdwrite();portb = 0x06; /向ddram写入一个字符后,ac自动加1;显示画面不移动lcdwrite();portb = 0x0f;/开显示,光标显示,闪烁lcdwrite();portb = 0x01;/清屏lcdwrite();lcdoutput(welcomelc

18、d);sei();/-lcd初始化 结束-/-lcd判忙 开始-void lcdbusytest(void) int busytest = 1;rs_clear; /指令rw_set; while(busytest=1) e_set; busytest = pinb&0x80; e_clear;/-lcd判忙 结束-/-lcd输出 开始-void lcdoutput(unsigned char message)unsigned char i = 0;cli();lcdbusytest();rs_clear; /指令portb = 0x03;lcdwrite();for(i=0;i16;i+)

19、if(i=8)lcdbusytest(); rs_clear; portb = 0x0c0; lcdwrite(); lcdbusytest();rs_set;portb = messagei;lcdwrite();sei();/-lcd输出 结束-/- check 开始-void check(void)unsigned char i = 0;passwordcheck = 0;for(i=0;i8;i+)if(inputpasswordi+8=passwordi)passwordcheck+;/- check 结束-/-主程序 开始-void main (void)unsigned char

20、 i = 0;initial();/系统初始化if(read_eeprom(0x10)=0x88)memoryread();state = 1;columnnum = 0;elsestate = 0;while(1)keyboard = pinc&0x3f;if(keyboard=0x2e)write_eeprom(0x08,0x00);state = 0;columnnum = 0;keyboard = 0xff;if(state=0)if(columnnum=0)lcdoutput(setpassword);lcdbusytest();rs_clear;portb = 0x0c0;lcdw

21、rite();columnnum = 1;switch(number)case 0:break;case 1:memorywrite();lcdoutput(save);for(i=0;i8;i+)setpasswordi+8 = ;state = 1;columnnum = 0;number = 0;break;case 2:if(setpasswordcolumnnum+7=0x39)setpasswordcolumnnum+7 = 0x30;lcdbusytest();rs_set;portb = setpasswordcolumnnum+7;lcdwrite();lcdbusytest

22、();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();delay(100);lcdbusytest();rs_set;portb = *;lcdwrite();lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;case 3:lcdoutput(cancel);for(i=0;i8;i+)setpasswordi+8 = ;state = 1;columnnum = 0;number = 0;break;case 4:if(colum

23、nnum=1)columnnum = 1;elsecolumnnum-;lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;case 5:if(setpasswordcolumnnum+70x30)setpasswordcolumnnum+7 = 0x30;elsesetpasswordcolumnnum+7-;if(setpasswordcolumnnum+7=8)columnnum = 8;elseif(setpasswordcolumnnum+7=0x30)columnnum+;

24、lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;elseif(columnnum=0)lcdoutput(inputpassword);lcdbusytest();rs_clear;portb = 0x0c0;lcdwrite();columnnum = 1;switch(number)case 0:break;case 1:memoryread();check();if(passwordcheck=8)/portd &= bit(4);lcdoutput(right);delay(30);/portd |= bit(4);else portd &= bit(4);lcdoutput(wrong);portd |= bit(4);for(i=0;i8;i+)inputpasswordi+8 = ;state = 1;columnnum = 0;number = 0;break;case 2:if(inputpasswordcolumnnu

温馨提示

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

评论

0/150

提交评论