调整完时间之后:
请输入密码,程序实时扫描矩阵键盘的输入:
密码输入正确的仿真效果图,继电器处于工作状态:
密码输入正确后3秒钟跳回时间显示:
密码输入出错时仿真效果图:
六、安装与调试
经过腐蚀制板、焊接元件,再上电调试各模块电路都能按照仿真里的正常工作。 初始上电的时候
LCD1602 上电显示:设置正常 其他状态都能正常显示 4*4矩阵键盘 独立按键 开锁驱动电路(8550驱动继电器) 各功能键正常工作,密码键正常输入 各功能键能正常工作 有开锁信号时继电器正常动作 七、结论与心得
八、参考文献
[1] 叶启明.单片机制作的新型安全密码锁[J].家庭电子.2000,第六期:24-27
[2] 郭海英.基于单片机的电子安全密码锁的设计[J].现代电子技术.2005,第三期:57-58 [3] 李明喜.新型电子密码锁的设计[J].机电产品开发与创新.2004,第八期:77-79 [4] 祖龙起.刘仁杰.孙乃凌.一种新颖的电子密码锁[J].电子世界.2001,第六期:88-90
[5] 李明喜.新型电子密码锁的设计[J].机电产品开发与创新.2004,第五期:22-28 [6] 长沙太阳人电子有限公司通用型1602液晶PDF资料. [7] 周立功单片机开发网. 附1:
程序清单如下: #include
#define uchar unsigned char #define uint unsigned int
#define no_key 20 //无按键时的返回值 sbit rs=P3^0;
sbit rw=P3^1;//lcd数据命令选择端 sbit e=P3^2;//lcd使能信号端 sbit key1=P3^3; sbit key2=P3^4;
sbit key3=P3^5;
sbit key=P3^7;//开锁信号控制端
sbit enter=P1^3;//该键按下后才能进行输入密码等操作 uchar conflag,keyflag=3; uchar jz=20;//键值变量
uchar temp1;//用此变量来存储键盘扫描的返回值,以便判断是否有键按下 uchar code table0[6]={3,0,3,0,3,0};//初始密码 uchar code table9[6]={3,1,3,1,3,1};//初始密码 uchar code table1[]=%uchar code table2[]=%uchar code table3[]=%uchar code table4[]=%uchar code table6[]=%uchar code table7[]=%uchar code table8[]=%uchar code table10[]=%uchar code table11[]=\
unsigned char m;
uchar num,t0,keynum,hour,min,sec,year,month,day,week; uchar table5[6];//定义输入密码值存储数组 /************************************** **函数名称:delay
**函数功能:软件延时,时间为z毫秒
**入口参数:z延时控制值,值越大,延时越长 **出口参数:无
***************************************/ void delay(uint z) {
uint x,y;
for(x=z;x>0;x--) for(y=110;y>0;y--); }
/************************************** **函数名称:write_com
**函数功能:1602写命令函数,可以用此函数写不同的指令 **入口参数:com **出口参数:无
***************************************/ void write_com(uchar com) { }
/************************************** **函数名称:write_date
**函数功能:1602写数据函数,可以用此函数写不同的数据,程序对应的硬件1602的数据口为P2口 **入口参数:date **出口参数:无
***************************************/ void write_date(uchar date) { rs=1; }
/*显示位*/
void write_week(uchar dte)
rs=0; rw=0; e=0; P2=com; delay(5); e=1; delay(5); e=0;
rw=0; e=0; P2=date; delay(5); e=1; delay(5); e=0;