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

边栏推荐
- [BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
- D25:sequence search (sequence search, translation + problem solving)
- Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Docking Alipay process [pay in person, QR code Payment]
- It is forbidden to splice SQL in code
- D27:mode of sequence (maximum, translation)
- [about text classification trick] things you don't know
- [GNN] hard core! This paper combs the classical graph network model
- AI Challenger 2018 text mining competition related solutions and code summary
猜你喜欢

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

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

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

Test the influence of influent swacth on the electromagnetic coil of quartz meter

Introducing Software Testing

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

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Tencent interview: can you find the number of 1 in binary?

A method to solve Bert long text matching

How to prevent malicious crawling of information by one-to-one live broadcast source server
随机推荐
NLP Chinese corpus project: large scale Chinese natural language processing corpus
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
2022 system integration project management engineer examination knowledge points: software development model
How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
leetcode-43. String multiplication
Solve the problem that the kaggle account registration does not display the verification code
Analysis: misunderstanding of choosing WMS warehouse management system
SQL data update
Gossip about redis source code 82
Analysis of refrigeration and air conditioning equipment operation in 2022 and examination question bank of refrigeration and air conditioning equipment operation
Briefly understand the operation mode of developing NFT platform
D30:color tunnels (color tunnels, translation)
The upload experience version of uniapp wechat applet enters the blank page for the first time, and the page data can be seen only after it is refreshed again
URL (data:image/png; Base64, ivborw0k... Use case
Detailed explanation of the relationship between Zhongtai, wechat and DDD
2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
D25:sequence search (sequence search, translation + problem solving)
Gossip about redis source code 78