当前位置:网站首页>STM32 key development foundation
STM32 key development foundation
2022-06-26 01:17:00 【m0_ forty-six million three hundred and twenty-one thousand one】
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 a resistor , The other end is grounded
When no key is pressed , The input pin is high , On the contrary, it is low level . By repeatedly reading the interval of this signal to determine whether there is a key trigger
To shake :
Influence of external noise , It may cause inaccurate reading level , At this time, it is necessary to shake , Remove the interference signal , So as to obtain the real key trigger signal
HAL Library level input function
Key signal recognition :HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uin16_t GPIO_Pin);
Identify level input , Enumerated 0 and 1 Two states
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)
# The high level is GPIO_PIN_SET, The low level is GPIO_PIN_RESET
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
}
To configure STM32CubeMX and keil5
The previous ones are similar , Set up , Input pin and output pin , Now you are configuring separate pins , choice PC13 Mouth and PB1 Two , Select pull up , It is convenient to identify these pins in the program .


Here, the above configuration codes are basically the same

Defines a read function , When the switch is pressed , Switch LED The state of , The second is to press and release before switching .

modify GPIO Definition of mouth , find gpio.c The file finds this structure , Observe the pins , You can modify it directly .
边栏推荐
- 2022年电气试验考试试题模拟考试平台操作
- 在线小工具分享(不定时更新,当前数量:2)
- C#另外一个new类的方式Ico?以及App.config的使用
- C#使用MySql进行操作
- Summary of push-pull output and open drain output of STM32 and failure of analog IIC driving mlx90615
- 案例:绘制Matplotlib动态图
- .net使用Access 2010数据库
- Template engine - FreeMarker first experience
- Android cache usage tool class
- 数字电路——加法器
猜你喜欢

ETCD数据库源码分析——集群通信初始化

Template engine - FreeMarker first experience

Installation and startup of redis

案例:绘制Matplotlib动态图

关于HC-12无线射频模块使用

About the use of hc-12 radio frequency module

15 `bs对象.节点名称.节点名称.string` 获取嵌套节点内容

ADC acquisition noise and comparison between RMS filter and Kalman filter

Mpu6050 reads the ID incorrectly and 0xd1 occurs (the correct ID should be 0x68 or 0x69). Solution.

Redis之Strings命令
随机推荐
网上开通证券账户安全吗 证券网上开户
《产品思维30讲》精华及感想
生信周刊第33期
远程增量同步神器rsync
A sharp tool for information collection, Google hacker syntax
ASP. Net cache cache usage
Template engine - FreeMarker first experience
Flex & Bison 开始
Duck feeding data instant collection solution resources
Solution to MySQL error code 2003
Nacos registry
Unknown device ID does not appear on the STM32 st-link utility connection! Causes and Solutions
Redis strings command
C disk cleaning strategy of win10 system
Solve STM32 operation μ Solution to sudden failure of task scheduling in c/os-ii system
Comment promouvoir efficacement les produits
Unified gateway
Endnote IEEE Transactions on industrial electronics/tie/tpel reference format template
Sword finger offer II 096 String interleaving
DGUS新升级:全面支持数字视频播放功能