STC89C52最小系统
此模块是为了控制相关门禁,或是一些特定情况下要用到比较高级的锁。DS1302时钟显示不用手动写时钟代码就很方便,这一次用的是stc89c52,就很熟悉。
总结一下:LCD1602是GND和5V接一起。
DS1302时钟模块确保3.3V就可以
AS608指纹模块调试他的波特率,单片机最小系统的晶振要是11.05926mH
要原理图,截屏的图片不知道咋样拉进来。就先这样吧
制作出来的实物图如下:
代码和文件都可以下载- #include <reg52.h>
- #include <intrins.h>
- #include "buzz.h"
- #include "key.h"
- #include "uart.h"
- #include "delay.h"
- #include "FPM10A.h"
- #include "lcd_1602.h"
- #include "ds1302.h"
- typedef unsigned int u16; //对数据类型进行声明定义
- typedef unsigned char u8;
- u8 DisplayData[16]=" - : : ";
- void datapros()
- {
- Ds1302ReadTime(); //反馈时间TIME
- DisplayData[1] = TIME[4]/16+0x30;
- DisplayData[2] = (int)(TIME[4]&0x0f)+0x30; //月
- DisplayData[4] = TIME[3]/16+0x30;
- DisplayData[5] = (int)(TIME[3]&0x0f)+0x30; //日
-
- DisplayData[7] = TIME[2]/16+0x30; //时
- DisplayData[8] = (int)(TIME[2]&0x0f)+0x30;
-
- // DisplayData[10] = ":";
- DisplayData[10] = TIME[1]/16+0x30; //分
- DisplayData[11] = (int)(TIME[1]&0x0f)+0x30;
- // DisplayData[13] = ":";
- // DisplayData[5] = ;
- DisplayData[13] = TIME[0]/16+0x30; //秒
- DisplayData[14] = (int)(TIME[0]&0x0f)+0x30;
- }
- void main()
- {
- u8 i;
- LCD1602_Init(); //初始化液晶
- LCD1602_Display(0x80,"Fingerprint Test",0,16); //液晶开机显示界面
- Uart_Init(); //初始化串口
- Key_Init(); //初始化按键
- while(1)
- {
- datapros(); //数据处理函数
- LCD1602_WriteCMD(0x80+0x40);
- for(i=0;i<16;i++)
- {
- LCD1602_WriteDAT(DisplayData[i]);
- }
- if(KEY_ENTER==0) //检测按键K1是否按下
- {
- Delay_Ms(10); //消除抖动 一般大约10ms
- if(KEY_ENTER==0) //再次判断按键是否按下
- {
- Delay_Ms(200); //延时500MS,等待指纹模块复位
- Device_Check(); //校对指纹模块是否接入正确,液晶做出相应的提示
- Delay_Ms(1000); //对接成功界面停留一定时间
- while(1)
- {
- /**************进入主功能界面****************/
- LCD1602_Display(0x80," search finger ",0,16); //第一排显示搜索指纹
- LCD1602_Display(0xc0," Add delete",0,16); //添加和删除指纹
- if(local_date==0)
- {
- LCD1602_Display(0x80, " *",0,2);
- LCD1602_Display(0xc0, " ",0,2);
- LCD1602_Display(0xc0+8," ",0,2);
- }
- else if(local_date==1)
- {
- LCD1602_Display(0x80, " ",0,2);
- LCD1602_Display(0xc0, " *",0,2);
- LCD1602_Display(0xc0+8," ",0,2);
- }
- else if(local_date==2)
- {
- LCD1602_Display(0x80, " ",0,2);
- LCD1602_Display(0xc0, " ",0,2);
- LCD1602_Display(0xc0+8," *",0,2);
- }
- //确认键
- if(KEY_OK == 0)
- {
- while(KEY_OK == 0);//等待松开按键
- switch(local_date)
- {
- case 0: //搜索指纹
- FPM10A_Find_Fingerprint();
- break;
-
- case 1: //添加指纹
- FPM10A_Add_Fingerprint();
- break;
-
- case 2: //清空指纹
- FPM10A_Delete_All_Fingerprint();
- break;
- }
- }
- //切换键
- if(KEY_DOWN == 0)
- {
- while(KEY_DOWN == 0); //等待松开按键
- if(local_date<=2)
- {
- local_date++;
- if(local_date==3)
- local_date=0;
- }
- }
- Delay_Ms(100); //延时判断100MS检测一次
- }
- }
- while(!KEY_ENTER); //检测按键是否松开
- }
- }
- }
复制代码
全部程序:
开发板:LCD1602 AS608 DS1302.rar
(131.93 KB, 下载次数: 89)
|