標(biāo)題: STM32按鍵程序 (查詢方式) [打印本頁]

作者: mfkfnhyxk123    時(shí)間: 2020-3-25 01:24
標(biāo)題: STM32按鍵程序 (查詢方式)
  1. /***************************************
  2. * 文件名  :main.c
  3. * 描述    :按下KEY1、KEY2,分別翻轉(zhuǎn)LED1、 LED2,采用查詢方式。         
  4. * 實(shí)驗(yàn)平臺(tái):MINI STM32開發(fā)板 基于STM32F103C8T6
  5. * 庫版本  :ST3.0.0

  6. *********************************************************/

  7. #include "stm32f10x.h"
  8. #include "led.h"
  9. #include "key.h"  


  10. int main(void)
  11. {   
  12.   SystemInit();        // 配置系統(tǒng)時(shí)鐘為72M        
  13.   LED_GPIO_Config(); //LED 端口初始化          
  14.   Key_GPIO_Config();//按鍵端口初始化


  15.   while(1)                           
  16.   {          
  17.         if( Key_Scan(GPIOA,GPIO_Pin_0) == KEY_ON  )         //判斷KEY1是否按下
  18.         {                       
  19.      GPIO_WriteBit(GPIOC, GPIO_Pin_13, (BitAction)((1-GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_13))));//LED1翻轉(zhuǎn)
  20.         }
  21.        
  22.                
  23.   }
  24. }
復(fù)制代碼


按鍵(查詢方式).7z

140.2 KB, 下載次數(shù): 16, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1