当前位置:网站首页>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 .
边栏推荐
- Installation and startup of redis
- 认识map
- Essence and thoughts of 30 lectures on product thinking
- Laravel基础课 路由和MVC——控制器
- 超详细SSM框架实现增删改查功能项目整体流程
- C#使用MySql进行操作
- 新库上线 | CnOpenData农产品批发价格数据
- The cache page stores the initial parameters after the route jump under the react + router framework
- 新库上线 | CnOpenData中国新房信息数据
- Motor monitoring system based on MCGS and stm32
猜你喜欢

halcon之区域:多种区域(Region)生成(4)

LabVIEW开发监控聚变实验脉冲电源

Dgus new upgrade: fully support digital video playback function

I2C protocol

vite打包构建时 @charset utf-8警告问题处理;

《网络是怎么样连接的》读书笔记 - 集线器、路由器和路由器(三)

Optimized three-dimensional space positioning method and its fast implementation in C language

Vscode shortcut

新库上线 | CnOpenData中国新房信息数据

Redis的安装及启动
随机推荐
信息收集的利器,Google骇客语法
Etcd database source code analysis cluster communication initialization
What training brings happiness
Endnote IEEE TRANSACTIONS ON INDUSTRIAL ELECTRONICS/TIE/TPEL 参考文献格式模板
Radio boxes are mutually exclusive and can be deselected at the same time
Typescript for Web Learning
SPI protocol
Android cache usage tool class
100ask seven day IOT training camp learning notes - bare metal program framework design
The kth largest element in the array
Establish a j-link GDB cross debugging environment for Px4
Error 65:access violation at 0x58024400: no 'read' permission
Native DOM vs. virtual DOM
使用Gin框架运行Demo时报错“ listen tcp :8080: bind: An attempt was made to access a socket in a way forbidden”
继承--圣杯模式
C # operate with MySQL
Web信息收集,互联网上的裸奔者
Black box test - decision table method of test cases
[机缘参悟-30]:鬼谷子-内揵篇-同理心,站在对方的立场,拉近与对方的心理距离
Summary of push-pull output and open drain output of STM32 and failure of analog IIC driving mlx90615