基于单片机语音智能密码锁设计(编辑修改稿)内容摘要:

存密码 、并且通过 LCD 显示屏和 LED 灯直观地显示各密码锁各种状态,用继电器模拟锁的状态,用户可以自定义设置 6 位的数字密码,系统还具有报警功能,该系统基本 能够实现本文能够提出的功能和要求。 本设计也存在不足,缺陷一,单重的密码锁不能满足较高的安全需要。 缺陷二,该系统对电的依赖比较大,必须使 24C04 一直保持供电状态,当断电后不能正常工作。 缺点三,在按键按下时,按键声不够响亮清晰,在仿真时显得反映21 比较慢,假如能采用语音模块,能用语音播报按键时密码所处状态,密码锁将会更具人性化。 通过这次对智能密码锁的设计,感受更多的是自己的能力有限,知识不够丰富,知识点掌握的不够扎实,使得自己不能按自己初始设想完成自己的设计,使得所设的密码锁不够完整。 在这次设计中还让 ,让我了解了实时控制的原理,懂得怎样合理的使用芯片,发挥其功能。 体会到做设计时必须有条理的按一定步骤实行系统的设计、各个步骤的实施。 总之,这次课程设计使在电路设计方面受益匪浅。 参考文献 [1] 林立 .张俊亮 .曹旭东 .刘得军 .单片机原理及应用 : 基于 Proteus和 Keil C [M].北京:电子工业出版社 , 2020: 25. [2] 郑锋 .王巧芝 .李英建 .刘瑞国 .51单片机应用系统典型模块开发大全 [M].北京:中国铁道出版社 ,2020: 520. [3] 张俊谟 .单片机中级教程 [M].北京:北京航空 航天大学出版 ,2020: 3645. [4] 单片机高级语言 C51 Windows环境编程与应用 [M],电子工业出版社, 2020: 8695. [5] AT89C51 DATA SHEEP[M] .Philips Semiconductors,1999: 1536. [6] 康华光 .电子技术基础 (第 5版 )[M].北京:高等教育出版社 ,2020: 4548. [7] 彭华林等编 .数字电子技术 [M].长沙:湖南大学出版社 ,2020: 4560. [8] 金唯香等编 .电子测试技术 [M].长沙:湖南大学出版社 ,2020: 2630. 22 附件 AT24C04头文件 include define uchar unsigned char define uint unsigned int sbit SDA = P3^4。 sbit SCL = P3^3。 bit ack。 void delayNOP()。 void I2C_start()。 void I2C_stop()。 void I2C_init()。 void I2C_Ack()。 void I2C_NAck()。 uchar RecByte()。 uchar SendByte(uchar write_data)。 uchar read_nbyte (uchar SLA,uchar SUBA,uchar *pdat,uchar n)。 uchar write_nbyte(uchar SLA,uchar SUBA,uchar *pdat,uchar n)。 void delayNOP() { _nop_()。 _nop_()。 _nop_()。 _nop_()。 } void I2C_start() { SDA = 1。 SCL = 1。 delayNOP()。 SDA = 0。 23 delayNOP()。 SCL = 0。 } void I2C_stop() { SDA = 0。 SCL = 1。 delayNOP()。 SDA = 1。 delayNOP()。 SCL = 0。 } void I2C_init() { SCL = 0。 I2C_stop()。 } void I2C_Ack() { SDA = 0。 SCL = 1。 delayNOP()。 SCL = 0。 SDA = 1。 } void I2C_NAck() { SDA = 1。 SCL = 1。 delayNOP()。 24 SCL = 0。 SDA = 0。 } uchar RecByte() { uchar i,read_data。 read_data=0x00。 SDA=1。 for(i = 0。 i 8。 i++) { SCL = 1。 read_data = 1。 read_data |= SDA。 delayNOP()。 SCL = 0。 delayNOP()。 } SCL = 0。 delayNOP()。 return(read_data)。 } uchar SendByte(uchar write_data) { uchar i。 for(i = 0。 i 8。 i++) { SDA = (bit)(write_data amp。 0x80)。 _nop_()。 _nop_()。 25 SCL = 1。 delayNOP()。 SCL = 0。 write_data = 1。 } delayNOP()。 SDA = 1。 SCL = 1。 delayNOP()。 if(SDA==1) ack=0。 else ack=1。 SCL = 0。 delayNOP()。 return ack。 } uchar write_nbyte(uchar SLA,uchar SUBA,uchar *pdat,uchar n) { uchar s。 I2C_start()。 SendByte(SLA)。 if(ack==0) return(0)。 SendByte(SUBA)。 if(ack==0) return(0)。 for(s=0。 sn。 s++) { SendByte(*pdat)。 if(ack==0) return(0)。 pdat++。 26 } I2C_stop()。 return(1)。 } uchar read_nbyte (uchar SLA,uchar SUBA,uchar *pdat,uchar n) { uchar s。 I2C_start()。 SendByte(SLA)。 if(ack==0) return(0)。 SendByte(SUBA)。 if(ack==0) return(0)。 I2C_start()。 SendByte(SLA+1)。 if(ack==0) return(0)。 for(s=0。 sn。 s++) { *pdat=RecByte()。 I2C_Ack()。 pdat++。 } I2C_NAck()。 I2C_stop()。 return(1)。 } 1602头文件 include include define uchar unsigned char define uint unsigned int 27 sbit LCD_RS=P2^0。 sbit LCD_RW=P2^1。 sbit LCD_EN=P2^2。 void Delay_ms(uint xms)。 bit lcd_busy()。 void lcd_wcmd(uchar cmd)。 void lcd_wdat(uchar dat)。 void lcd_clr()。 void lcd_init()。 void Delay_ms(uint xms) { uint i,j。 for(i=xms。 i0。 i) for(j=110。 j0。 j)。 } bit lcd_busy() { bit result。 LCD_RS = 0。 LCD_RW = 1。 LCD_EN = 1。 _nop_()。 _nop_()。 _nop_()。 _nop_()。 result = (bit)(P0amp。 0x80)。 LCD_EN = 0。 return result。 28 } void lcd_wcmd(uchar cmd) { while(lcd_busy())。 LCD_RS = 0。 LCD_RW = 0。 LCD_EN = 0。 _nop_()。 _nop_()。 P0 = cmd。 _nop_()。 _nop_()。 _nop_()。 _nop_()。 LCD_EN = 1。 _nop_()。 _nop_()。 _nop_()。 _nop_()。 LCD_EN = 0。 } void lcd_wdat(uchar dat) { while(lcd_busy())。 LCD_RS = 1。 LCD_RW = 0。 LCD_EN = 0。 P0 = dat。 _nop_()。 29 _nop_()。 _nop_()。 _nop_()。 LCD_EN = 1。 _nop_()。 _nop_()。 _nop_()。 _nop_()。 LCD_EN = 0。 } void lcd_clr() { lcd_wcmd(0x01)。 Delay_ms(5)。 } void lcd_init() { Delay_ms(15)。 lcd_wcmd(0x38)。 Delay_ms(5)。 lcd_wcmd(0x38)。 Delay_ms(5)。 lcd_wcmd(0x38)。 Delay_ms(5)。 lcd_wcmd(0x0c)。 Delay_ms(5)。 lcd_wcmd(0x06)。 30 Delay_ms(5)。 lcd_wcmd(0x01)。 Delay_ms(5)。 } 设定初始密码程序 include include include define uchar unsigned char define uint unsigned int uchar code_buf[6]={1,2,3,4,5,6}。 uchar key。 uchar temp。 sbit BEEP=P3^7。 void beep() { BEEP=0。 Delay_ms(100)。 BEEP=1。 Delay_ms(100)。 } void MatrixKey() { P1=0xff。 P1=0xef。 temp=P1。 temp=temp amp。 0x0f。 if (temp!=0x0f) 31 { Delay_ms(10)。 temp=P1。 temp=temp amp。 0x0f。 if (temp!=0x0f) { temp=P1。 switch(temp) { case 0xee:key=0。 break。 case 0xed:key=1。 break。 case 0xeb:key=2。 break。 case 0xe7:key=3。 break。 } temp=P1。 beep()。 temp=temp amp。 0x0f。 while(temp!=0x0f) { temp=P1。 temp=temp amp。 0x0f。 } } } P1=0xff。 P1=0xdf。 temp=P1。 temp=temp amp。 0x0f。 if (temp!=0x0f) { 32 Delay_ms(10)。 temp=P1。 temp=temp amp。 0x0f。 if (temp!=0x0f) { temp=P1。 switch(temp) { case 0xde:key=4。 break。 case 0xdd:key=5。 break。 case 0xdb:key=6。 break。 case 0xd7:key=7。 break。 } temp=P1。 beep()。 temp=temp amp。 0x0f。 while(temp!=0x0f) {。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。