




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、四个部分 很简单的写法 适合大部分人群! 欢迎下载! /*无存储功能电子密码锁*/*头文件*#include"reg52.h"#include"speak.h"#include"lcd_1602.h"#include"keysca.h"/*变量定义*unsigned int shurumima6;/*主函数*void main()init_1602(); /初始化while(1)duoyu_1602();keyscan();、#include"reg52.h"#include"lcd_
2、1602.h"/*sbit rw=P02; sbit rs=P03; sbit en=P01;unsigned char code yejing='z','h','o','u','a','i','u','*'unsigned int mima_init;extern unsigned int shurumima6;/*写命令、数据*void write(unsigned char date,unsigned char k)1 / 6rs=k;P2=date;
3、delay1ms(5);en=1;delay1ms(5);en=0;/*液晶初始化*void init_1602()en=0;rw=0;write(0x38,0);write(0x0c,0);write(0x06,0);write(0x01,0); /*1ms延时函数*void delay1ms(unsigned int z) /1ms延时unsigned int x,y;for(x=z;x>0;x-)for(y=120;y>0;y-);/*液晶多余部分显示*void duoyu_1602()unsigned char i;write(0x80+0x40,0);write(yeji
4、ng7,1);write(0x80+0x41,0);for(i=0;i<4;i+) write(yejingi,1);write(0x80+0x45,0);write(yejing1,1);write(0x80+0x46,0);write(yejing4,1);write(0x80+0x47,0);write(yejing2,1);write(0x80+0x48,0);write(yejing0,1);write(0x80+0x49,0);write(yejing1,1);write(0x80+0x4a,0);write(yejing5,1);write(0x80+0x4b,0);wri
5、te(yejing0,1);write(0x80+0x4c,0);write(yejing6,1);write(0x80+0x4d,0);write(yejing2,1);write(0x80+0x4e,0);write(yejing7,1);write(0x80+0x4f,0);write(yejing7,1);write(0x80,0);for(i=0;i<5;i+) write(yejing7,1);write(0x80+0x0b,0);write(yejing7,1);write(0x80+0x0c,0);write(yejing7,1);write(0x80+0x08,0);f
6、or(i=1;i<4;i+) write(shurumimai+0x30,1);write(0x80+0x0d,0);for(i=1;i<4;i+) write(mima_initi+0x30,1);、#include"reg52.h"#include"lcd_1602.h"#include"keysca.h"#include"speak.h"/*unsigned int low,high,number,qout,j;unsigned char ok,shuru,gaimi,gaimi_count,sh
7、uru_count,ok_count,succeed_flag,m,n;extern unsigned int shurumima6;unsigned int mima_init=0,1,2,3;unsigned int code please='p','l','e','a','s','e'/please unsigned int code sr='s','r'/shuruunsigned int code gm='g','m'/gai
8、miunsigned int code ookk='o','k'/ok/*void keyscan()P1=0X0F;low=P1&0x0f;if(low!=0x0f)delay1ms(10);low=P1&0x0f;P1=0XF0;high=P1&0xf0;if(high!=0xf0)delay1ms(10);high=P1&0xf0;number=low+high;switch(number)case(0x77): qout=0;write(0x80+0x07,0);write('0',1);break;cas
9、e(0x7b): qout=1;write(0x80+0x07,0);write('1',1);break;case(0x7d): qout=2;write(0x80+0x07,0);write('2',1);break;case(0x7e): qout=3;write(0x80+0x07,0);write('3',1);break;case(0xb7): qout=4;write(0x80+0x07,0);write('4',1);break;case(0xbb): qout=5;write(0x80+0x07,0);write
10、('5',1);break;case(0xbd): qout=6;write(0x80+0x07,0);write('6',1);break;case(0xbe): qout=7;write(0x80+0x07,0);write('7',1);break;case(0xd7): qout=8;write(0x80+0x07,0);write('8',1);break;case(0xdb): qout=9;write(0x80+0x07,0);write('9',1);break;case(0xdd): ;break
11、;case(0xde): ;break;case(0xe7): shuru=1;write(0x80+0x05,0);for(j=0;j<2;j+) write(srj,1);break;case(0xeb): gaimi=1;write(0x80+0x05,0);for(j=0;j<2;j+) write(gmj,1);break;case(0xed): ;break;case(0xee): ok=1;write(0x80+0x05,0);for(j=0;j<2;j+) write(ookkj,1);break;if(gaimi=1&&shuru=1)/改密
12、码mima_initgaimi_count=qout;gaimi_count+;if(shuru=1&&gaimi=0)/输入密码shurumimashuru_count=qout;shuru_count+;if(ok=1)if(shuru=1&&gaimi=0)/输入密码确认for(ok_count=1;ok_count<4;ok_count+)if(shurumimaok_count!=mima_initok_count) succeed_flag=2;break;if(succeed_flag!=2) succeed_flag=1;ok=0;shuru=0;shuru_count=0;if(gaimi=1&&shuru=1)/修改密码确认gaimi_count=0;gaimi=0;ok=0;while(P1!=0XF0);if(succeed_flag=1)succeed();m+;if(m=10) succeed_flag=0;m=0;else if(succeed_flag=2)speak_led();n+;if(n=10) succeed_flag=0;n=0;。/*#include"reg52.h"#include"lcd_1602.h"#include"sp
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度拆除工程风险评估及应急预案
- 2025年度新能源项目场站建设与运营管理合同
- 2025年度电池储能系统设计与集成服务合同
- 2025年度商业秘密保护保密劳动合同及保密协议
- 2025年度城市道路临时停车位租赁及交通管理合同
- 2025年度彩钢板隔墙快速安装服务合同
- 2025年度体育赛事赞助商提成协议
- 2025年冷墩钢合作协议书
- 如何选择理财顾问计划
- 多元文化背景下的艺术教育计划
- 实验动物饲养人员岗位竞聘演讲范文汇报报告范文
- 商业地产市场竞品楼盘市场调研表格
- SMT失效模式分析PFMEA
- 国际贸易地理全套课件
- 家校共育-助孩子成长-家长会课件
- 叉形件工艺及车床夹具设计说明书
- GB/T 709-2019热轧钢板和钢带的尺寸、外形、重量及允许偏差
- GB/T 5916-2008产蛋后备鸡、产蛋鸡、肉用仔鸡配合饲料
- GB/T 14177-2003林业机械便携式割灌机和割草机试验方法
- 安全测试工具、蹭网利器wifiphisher新增汉化版
- 中学教育-中学生心理健康量表参考范本
评论
0/150
提交评论