標(biāo)題: stm32解碼紅外管,定時器捕捉方式源碼 [打印本頁]

作者: 周英俊    時間: 2018-9-6 10:17
標(biāo)題: stm32解碼紅外管,定時器捕捉方式源碼
利用STM32的定時器捕捉的方式進(jìn)行解碼,解出來的鍵碼顯示在oled上。

單片機(jī)源程序如下:
  1. #include "led.h"
  2. #include "oled.h"
  3. #include "delay.h"
  4. #include "key.h"
  5. #include "sys.h"
  6. #include "lcd.h"
  7. #include "remote.h"



  8. u16 key,voule,times;

  9. int main(void)
  10. {         
  11.        
  12.         delay_init();                     //延時函數(shù)初始化          
  13.   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級分組為組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
  14.         LED_Init();                             //LED端口初始化
  15.         KEY_Init();                
  16.         Remote_Init();                        //紅外接收初始化               
  17.         OLED_Init();
  18. //Draw_Logo();
  19.   OLED_Fill(0x00);         
  20.   LED0=1;
  21.   OLED_ShowString1(0,0,"Key_code:");                                                                                                         
  22.         while(1)
  23.         {
  24.                 key=Remote_Scan();       
  25.                 if(key)
  26.                 {         
  27.                           OLED_P8x16Num_8bit(85,0,key);
  28.                           voule=key;
  29.                                 LED0=!LED0 ;       
  30.                           times++;  
  31.                 }       
  32.                 else
  33.                 {
  34.                         OLED_P8x16Num_8bit(0,6,times);
  35.                         delay_ms(10);
  36.                 }  
  37.                
  38.         }
  39. }
復(fù)制代碼

所有資料51hei提供下載:
實驗27 紅外遙控實驗.rar (342.66 KB, 下載次數(shù): 21)







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