当前位置:网站首页>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);
}

边栏推荐
- Entropy and full connection layer
- Several ways to set up a blog locally [attach relevant software download links]
- Solve the problem that the kaggle account registration does not display the verification code
- Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
- D30:color tunnels (color tunnels, translation)
- Gossip about redis source code 82
- EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
- Idea integrates Microsoft TFs plug-in
- 2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
- After the Lunar New Year and a half
猜你喜欢

"Learning notes" recursive & recursive

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival

Joint examination of six provinces 2017

Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition

How to write a good title of 10w+?

Detailed explanation of the relationship between Zhongtai, wechat and DDD

Analysis of refrigeration and air conditioning equipment operation in 2022 and examination question bank of refrigeration and air conditioning equipment operation

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

It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something

Idea a method for starting multiple instances of a service
随机推荐
Gossip about redis source code 81
Reading notes on how programs run
D27:mode of sequence (maximum, translation)
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
What are the application fields of digital twins in industry?
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
Gossip about redis source code 83
Vscode regular match replace console log(.*)
C # basic knowledge (1)
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Is user authentication really simple
Detailed explanation of the relationship between Zhongtai, wechat and DDD
C # basic knowledge (2)
Solve the problem that the kaggle account registration does not display the verification code
SPI based on firmware library
Generic tips
Sword finger offer day 4 (Sword finger offer 03. duplicate numbers in the array, sword finger offer 53 - I. find the number I in the sorted array, and the missing numbers in sword finger offer 53 - ii
Actual combat | use composite material 3 in application
The interviewer's biggest lie to deceive you, bypassing three years of less struggle
2/14 (regular expression, sed streaming editor)