当前位置:网站首页>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【下方分享一些免费教程资料,大家感兴趣的可以看一下】:
边栏推荐
- 如何利用原生JS实现回到顶部以及吸顶效果
- J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
- UOJ#749-[UNR #6]稳健型选手【贪心,分治,主席树】
- Kunpeng compilation and debugging and basic knowledge of native development tools
- HW-蓝队工作流程(1)
- 有哪些可以投稿软件工程/系统软件/程序设计语言类外文期刊、会议?
- Dump文件生成,内容,以及分析
- YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
- IEEE的论文哪里可以下载?
- 【21天学习挑战赛】折半插入排序
猜你喜欢

Only lazy and hungry. You still don't understand the singleton pattern!

力扣------使用最小花费爬楼梯

Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本

复制带随机指针的链表——LeetCode

ArcGIS Pro 创建tpk

【redis】发布和订阅消息

I caught a 10-year-old Ali test developer, and after talking about it, I made a lot of money...

异常:try catch finally throws throw

Jvm.分析工具(jconsole,jvisualvm,arthas,jprofiler,mat)

IEEE的论文哪里可以下载?
随机推荐
【爬虫】scrapy创建运行爬虫、解析页面(嵌套url)、自定义中间件(设置UserAgent和代理IP)、自定义管道(保存到mysql)
时间戳转换为日期格式、获取当前时间戳
“蔚来杯“2022牛客暑期多校训练营2 DGHJKL题解
Design and Realization of Employment Management System in Colleges and Universities
[21天学习挑战赛——内核笔记](五)——devmem读写寄存器调试
Based on the SSM to reach the phone sales mall system
深度解析volatile关键字(保证够全面)
14. Thymeleaf
使用mysql语句操作数据表(table)
[数据可视化] 图表设计原则
EN 12467纤维水泥平板产品—CE认证
Lens filter---about day and night dual-pass filter
Mysql数据库安装配置详细教程
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
ArcGIS Pro 创建tpk
SAP ABAP JSON 格式数据处理
[Excel knowledge and skills] Convert text numbers to numeric format
鲲鹏编译调试及原生开发工具基础知识
C# using timer
什么是数组