功能介绍:
0.本系统采用STM32F103C8T6作为单片机
1.采用LCD1602液晶实时显示设置和输入的信息
2.使用矩阵键盘设置和输入密码等参数
3.采用多路开关CD4051实现24通道的控制
4.采用DC002作为电源接口可直接输入5V给整个系统供电
原理图:
PCB:
主程序:
#define __MAIN_C
#include "main.h"
#include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "bsp_gpio.h"
#include "bsp_clkconfig.h"
#include "bsp_delay.h"
#include "bsp_lcd1602.h"
#include "bsp_keyArray.h"
#include "stdio.h"enum _MODE_DF_ dispMode;
CreatByte Flag;
CreatSPE LockerInformation[24]; //创建密码结构体,柜子状态,密码,密码错误次数uint16_t passwd = 0;
uint8_t inpPasswd[4] = {0}; //输入密码uint8_t count_num = 0;
uint16_t adminPasswd[4] = {1, 2, 3, 4};int main(void)
{ uint8_t i;uint8_t j;char keyCode = 0;// 使用HSI,SYSCLK = 4M * RCC_PLLMul_x, x:[2,3,...16],最高是64MHHSI_SetSysClock(RCC_PLLMul_2); //使用内部8MHz晶振,并设置PLL输出为8MHzfor (i = 0; i< 24; i++){LockerInformation[i].status = 0;for (j = 0; j< 4; j++){LockerInformation[i].password[j] = 255;}LockerInformation[i].errcnt = 0;}// LED 端口初始化GPIO_Config();KeyArray_GPIO_Init();LCD_GPIO_Init();LCD_Init();LCD_Clear();keyCode = KeyScan();if (keyCode == '#') //开机过程按下#号键,可重置密码柜{WriteIntFlash(); //初始化数据}ReadIntFlash();while (1){ KeyFunction();passwd++;if (passwd >= 999){passwd = 0;}}
}/*********************************************END OF FILE**********************/
实物演示视频:
https://www.bilibili.com/video/BV1Mt4y1A7Yg/