当前位置:网站首页>STM32 key light
STM32 key light
2022-07-04 00:08:00 【Flamingo39】
STM32 Key development
The basic principle of key scanning
Key signal recognition
Generally speaking , One end of the two pins of the key is pulled up to the high level through the resistance , The other end is grounded . stay There is no key press When , The input pin is high , When There are buttons to press , The input pin is low . By repeatedly reading the signal of the key input pin , Then identify the high and low level to judge whether there is a key trigger .
Why shake
The low level of the input pin of the key does not mean that the key must be pressed , Maybe it's a jamming signal , therefore , It needs to be processed by de dithering , Filter these interference signals , So as to obtain the real key trigger signal .
How to shake
After detecting the low level of the key input pin for the first time , A little delay , Read the pin again , If it is still low , It is confirmed as the key trigger signal ; otherwise , Judged as interference signal , Not to deal with .
GPIO Input level reading HAL Library function
GPIO_PinState HAL_GPIO_ReadPin( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Parameters 1:GPIOx, Port number , Such as :GPIOB,GPIOF.
Parameters 2:GPIO_Pin, Pin number , Such as :GPIO_PIN_9,GPIO_PIN_12.
Return value :GPIO_PinState, The level state of the pin .
Application, for example, : Judge PC13 Input signal of pin , If high , Will PB9 Pin controlled LED The switch state of the lamp is switched .
if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
}

边栏推荐
- Smart fan system based on stm32f407
- NLP Chinese corpus project: large scale Chinese natural language processing corpus
- Analysis: misunderstanding of choosing WMS warehouse management system
- ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
- [C language] break and continue in switch statement
- Gossip about redis source code 77
- Distributed transaction -- middleware of TCC -- selection / comparison
- Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
- A method to solve Bert long text matching
- [about text classification trick] things you don't know
猜你喜欢

Double efficiency. Six easy-to-use pychar plug-ins are recommended

MySQL is installed as a Windows Service

Pytorch learning notes 5: model creation

How to make recv have a little temper?

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
![P3371 [template] single source shortest path (weakened version)](/img/c5/bcb22e1ea573253005e56ebbd73bb7.jpg)
P3371 [template] single source shortest path (weakened version)

How to make icons easily

Analysis on the scale of China's smart health industry and prediction report on the investment trend of the 14th five year plan 2022-2028 Edition

MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
随机推荐
2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) simulated examination and Guangdong Provincial Safety Officer a certificate third batch (main person in charg
Powerful blog summary
Fluent learning (4) listview
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
2022 t elevator repair registration examination and the latest analysis of T elevator repair
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Introducing Software Testing
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
[leetcode] interview question 17.08 Circus tower
Several ways to set up a blog locally [attach relevant software download links]
D29:post Office (post office, translation)
STM32 GPIO CSDN creative punch in
1214 print diamond
Zipper table in data warehouse (compressed storage)
P1656 bombing Railway
Alibaba cloud container service differentiation SLO hybrid technology practice
What is the Valentine's Day gift given by the operator to the product?
Detailed explanation of the relationship between Zhongtai, wechat and DDD
Unity elementary case notes of angry birds Siki college 1-6
Shell script three swordsman sed