使用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)
2018-9-10 16:55 上傳
點擊文件名下載附件
|