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

边栏推荐
- It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
- [Mongodb] 2. Use mongodb --------- use compass
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Iclr2022: how does AI recognize "things I haven't seen"?
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Vscode regular match replace console log(.*)
- Data storage - interview questions
- 2022 t elevator repair registration examination and the latest analysis of T elevator repair
- 2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
- How can I get the Commission discount of stock trading account opening? Is it safe to open an account online
猜你喜欢

2022 a special equipment related management (elevator) examination questions and a special equipment related management (elevator) examination contents

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method

Vscode regular match replace console log(.*)

NLP pre training technology development

What is the Valentine's Day gift given by the operator to the product?

How will the complete NFT platform work in 2022? How about its core functions and online time?
![[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections](/img/c6/3dc7d01600f6713afdbb4cf3df5238.jpg)
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections

How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
![[MySQL] classification of multi table queries](/img/96/2e51ae8d52ea8184945e0540ce18f5.jpg)
[MySQL] classification of multi table queries

Double efficiency. Six easy-to-use pychar plug-ins are recommended
随机推荐
2022 examination of safety production management personnel of hazardous chemical production units and examination skills of safety production management personnel of hazardous chemical production unit
【leetcode】374. Guess the size of the number
想请教一下,十大劵商如何开户?在线开户是安全么?
NLP pre training technology development
Is user authentication really simple
Gossip about redis source code 83
D24:divisor and multiple (divisor and multiple, translation + solution)
EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
D29:post Office (post office, translation)
SQL data update
What are the securities companies with the lowest Commission for stock account opening? Would you recommend it? Is it safe to open an account on your mobile phone
Fudan 961 review
Solve the problem that the kaggle account registration does not display the verification code
Analysis of refrigeration and air conditioning equipment operation in 2022 and examination question bank of refrigeration and air conditioning equipment operation
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Gossip about redis source code 78
Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
AI Challenger 2018 text mining competition related solutions and code summary
[leetcode] interview question 17.08 Circus tower
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