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

边栏推荐
- EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
- Idea a method for starting multiple instances of a service
- How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
- D23:multiple of 3 or 5 (multiple of 3 or 5, translation + solution)
- leetcode-43. String multiplication
- P1339 [USACO09OCT]Heat Wave G
- [MySQL] classification of multi table queries
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- URL (data:image/png; Base64, ivborw0k... Use case
- 炒股開戶傭金優惠怎麼才能獲得,網上開戶安全嗎
猜你喜欢

2022 system integration project management engineer examination knowledge points: software development model

"Learning notes" recursive & recursive
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/3f/75b3125f8779e6cf9467a30fd7eeb4.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!

How to make icons easily

A treasure open source software, cross platform terminal artifact tabby

Entropy and full connection layer

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
![[CSDN Q & A] experience and suggestions](/img/db/dff3173dda24ca5740729b54a81153.jpg)
[CSDN Q & A] experience and suggestions

Alibaba cloud container service differentiation SLO hybrid technology practice

MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
随机推荐
D24:divisor and multiple (divisor and multiple, translation + solution)
How to make icons easily
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Private project practice sharing populate joint query in mongoose makes the template unable to render - solve the error message: syntaxerror: unexpected token r in JSON at
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
Gossip about redis source code 83
Docking Alipay process [pay in person, QR code Payment]
[GNN] hard core! This paper combs the classical graph network model
Pytorch learning notes 5: model creation
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
How to prevent malicious crawling of information by one-to-one live broadcast source server
股票開戶傭金最低的券商有哪些大家推薦一下,手機上開戶安全嗎
Stock price forecast
D27:mode of sequence (maximum, translation)
【leetcode】374. Guess the size of the number
[PHP basics] session basic knowledge, application case code and attack and defense
leetcode-43. String multiplication
2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
Gossip about redis source code 80