当前位置:网站首页>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);
}
边栏推荐
- (Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
- C # basic knowledge (1)
- SPI based on firmware library
- ITK learning notes (VII) the position of ITK rotation direction remains unchanged
- "Learning notes" recursive & recursive
- NLP Chinese corpus project: large scale Chinese natural language processing corpus
- C # basic knowledge (2)
- URL (data:image/png; Base64, ivborw0k... Use case
- Advanced C language - pointer 2 - knowledge points sorting
- [leetcode] interview question 17.08 Circus tower
猜你喜欢
Is user authentication really simple
Alibaba cloud container service differentiation SLO hybrid technology practice
China standard gas market prospect investment and development feasibility study report 2022-2028
[Mongodb] 2. Use mongodb --------- use compass
Vscode regular match replace console log(.*)
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Deep learning ----- using NN, CNN, RNN neural network to realize MNIST data set processing
What does redis do? Redis often practices grammar every day
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
How to prevent malicious crawling of information by one-to-one live broadcast source server
随机推荐
Introducing Software Testing
How can I get the Commission discount of stock trading account opening? Is it safe to open an account online
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
Gossip about redis source code 79
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
Make small tip
Smart fan system based on stm32f407
How to solve the "safe startup function prevents the operating system from starting" prompt when installing windows10 on parallel desktop?
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)
Selenium library 4.5.0 keyword explanation (III)
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
Is the low commission link on the internet safe? How to open an account for China Merchants Securities?
EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
【leetcode】374. Guess the size of the number
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
Pytorch learning notes 5: model creation
ISBN number
Vscode regular match replace console log(.*)