使用STM32制作一个矩阵键盘密码锁,源码附上,菜鸡一个,大家一起交流。
单片机源程序如下:
- /******************************************
- ***程序:简易矩阵键盘密码锁********************
- ******************************************* _oo0oo_
- ** 连接方式: ***************************** o8888888o
- ******************************************* 88" . "88
- ************** PA0--IN1 *************** (| -_- |)
- ************** PA1--IN2 *************** 0\ = /0
- ************** PA2--IN3 *************** ___/`---'\___
- ************** PA3--IN4 *************** .' \\| |// '.
- ************** PA4--IN5 *************** / \\||| : |||// \
- ************** PA5--IN6 *************** / _||||| -:- |||||- \
- ************** PA6--IN7 *************** | | \\\ - /// | |
- ************** PA7--IN8 *************** | \_| ''\---/'' |_/ |
- ******************************************* \ .-\__ '-' ___/-. /
- ******************************************* ___'. .' /--.--\ `. .'___
- ******************************************* ."" '< `.___\_<|>_/___.' >' "".
- ******************************************* | | : `- \`.;`\ _ /`;.`/ - ` : | |
- ******************************************* \ \ `_. \_ __\ /__ _/ .-` / /
- ******************************************* =====`-.____`.___ \_____/___.-`___.-'=====
- ******************************************* `=---='
- ******************************************* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *******************************************
- **PA0-3口配置成推挽输出 作为4x4键盘的行******* 佛祖保佑 永无BUG
- **PA4-7口配置成上拉输入 作为4x4键盘的列*******
- *******************************************
- ******************************************/
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "beep.h"
- #include "usart.h"
- #include "string.h"
- #include "timer.h"
- #include "LOCK.h"
- int main(void)
- {
- delay_init();
- LED_Init();
- KEY_Init();
- uart_init(9600);
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- TIM3_Int_Init(4999,7199);
-
- printf("\n请输入\n");
- while(1)
- {
- LOCK();
- }
- }
复制代码
所有资料51hei提供下载:
JuZhengKey.rar
(290.52 KB, 下载次数: 94)
|