標(biāo)題:
STM32按鍵程序 (查詢方式)
[打印本頁]
作者:
mfkfnhyxk123
時(shí)間:
2020-3-25 01:24
標(biāo)題:
STM32按鍵程序 (查詢方式)
/***************************************
* 文件名 :main.c
* 描述 :按下KEY1、KEY2,分別翻轉(zhuǎn)LED1、 LED2,采用查詢方式。
* 實(shí)驗(yàn)平臺(tái):MINI STM32開發(fā)板 基于STM32F103C8T6
* 庫版本 :ST3.0.0
*********************************************************/
#include "stm32f10x.h"
#include "led.h"
#include "key.h"
int main(void)
{
SystemInit(); // 配置系統(tǒng)時(shí)鐘為72M
LED_GPIO_Config(); //LED 端口初始化
Key_GPIO_Config();//按鍵端口初始化
while(1)
{
if( Key_Scan(GPIOA,GPIO_Pin_0) == KEY_ON ) //判斷KEY1是否按下
{
GPIO_WriteBit(GPIOC, GPIO_Pin_13, (BitAction)((1-GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_13))));//LED1翻轉(zhuǎn)
}
}
}
復(fù)制代碼
按鍵(查詢方式).7z
2020-3-25 16:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
140.2 KB, 下載次數(shù): 16, 下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1