当前位置:网站首页>Single-chip human-computer interaction--matrix key
Single-chip human-computer interaction--matrix key
2022-08-11 00:34:00 【an520_】
The key is a normally open push button switch,The common connection method with the single-chip microcomputer is shown in the figure.The two contacts open when the key is not pressed,单片机I/O口输入高电平;当按键闭合时,I/O口输入低电平.
一、button explanation
当I/O口为P0口时,由于没有内部上拉电阻,Therefore, an external pull-up resistor is required,当I/O口为P1、P2和P3口时,Because of the internal pull-up resistor,Therefore, the external pull-up resistor can be omitted.
二、按键消抖
The keyboards used in the single-chip system are all mechanical elastic keys,Because of the elastic effect of mechanical contacts,Jitter occurs at the moment when the key is closed and released,如图所示.Keystroke jitter generally persists5~10ms,In order for a keypress to be processed only once,Keystroke jitter must be eliminated.To eliminate key jitter, software debounce or hardware debounce can be used.
Software debounce refers to when it detects that a key is closed,Check again after a short delay,If key closure is still detected,The button is considered to be truly closed.
Hardware debounce method
1.R-S触发器
一旦有键按下,The trigger reverses immediately,The jitter of the contacts will no longer affect the output,The same is true when the key is released.
2.电容滤波
Connect a capacitor in parallel across the buttons,Take advantage of the time-delay characteristics of capacitor discharge,The jittering level is absorbed by the capacitor,So as to achieve the effect of anti-vibration;
三、独立按键
Independent keyboard means that each key occupies an independent pin.
四、矩阵按键
All keys on the same row are connected to one pin,All keys on the same column are connected to one pin.
(1)Column scan method
All row lines output high level,The column lines output low level in turn;Query the value on the row of this column,若为0,It means that the button on the row is pressed;If all rows on this column have the value 1,Then the query for the next column row value is performed;循环往复.
(2)反转法
All row lines are output0,Query the value on the column line,If the value on a column line is 0,It means that the button on the line is pressed;Then all column lines are output0,Query the value on the row line,If the value on a line is 0,It means that the button on the line is pressed;Thereby, it is determined that the button of a certain row and a certain column is pressed.
五、程序举例
【Learn the technology crowd:197416462】
【网盘免费资料包,大家需要的自行领取】:
嵌入式物联网 22个STM32项目、大赛作品,【华清远见发放资料包】http://makerschool.mikecrm.com/f4wjYBB【下方分享一些免费教程资料,大家感兴趣的可以看一下】:
边栏推荐
- NOR FLASH闪存芯片ID应用之软件保护场景
- YOLOv5的Tricks | 【Trick11】在线模型训练可视化工具wandb(Weights & Biases)
- 3d打印出现stl文件物体不是流形,意味着不是水密体...解决办法
- EPro-PnP: Generalized End-to-End Probabilistic Perspective-n-Points for Monocular Object Pose Est...
- 微信小程序获取当前页面的url和参数
- 嵌入式软件打log的一些心得
- Dump file generation, content, and analysis
- Exceptions and exception handling mechanisms
- C# JObject解析JSON数据
- 异常:try catch finally throws throw
猜你喜欢
学习Apache ShardingSphere解析器源码(一)
Where can I download IEEE papers?
只会懒汉式和饿汉式 你还不懂单例模式!
报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
How engineers treat open source
Qt入门(六)——抽奖系统的实现
More parameter exposure of Pico 4: Pancake + color perspective, and Pro version
Shell编程三剑客之sed
二维数组实战项目--------《扫雷游戏》
Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本
随机推荐
electron -autoUpdater 更新
关于编程本质那些事
Based on the SSM to reach the phone sales mall system
只会懒汉式和饿汉式 你还不懂单例模式!
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
Only lazy and hungry. You still don't understand the singleton pattern!
力扣------使用最小花费爬楼梯
[Excel知识技能] 将“假“日期转为“真“日期格式
How to check if the online query suddenly slows down
① 数据库介绍 及 关系型数据库的关系代数表达式
Dump文件生成,内容,以及分析
镜头之滤光片---关于日夜两用双通滤光片
详解JDBC的实现与优化(万字详解)
深度解析volatile关键字(保证够全面)
Some Experiences of Embedded Software Logging
EN 12467纤维水泥平板产品—CE认证
Design and Realization of Employment Management System in Colleges and Universities
关于科研学习中的几个问题:如何看论文?如何评价工作?如何找idea?
虚拟电厂可视化大屏,深挖痛点精准减碳
【pypdf2】安装、读取和保存、访问页面、获取文本、读写元数据、加密解密