標(biāo)題: 基于stm32的隧道照明相關(guān)程序 [打印本頁(yè)]

作者: 滴滴答答穿秋褲    時(shí)間: 2020-5-19 14:09
標(biāo)題: 基于stm32的隧道照明相關(guān)程序
涉及紅外車速檢測(cè),光照檢測(cè),以及pwm調(diào)光
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "key.h"
  4. #include "led.h"
  5. //#include "usart.h"
  6. #include "hx711.h"
  7. #include "exti.h"       
  8. #include "timer.h"
  9. #include "oled.h"
  10. #include "adc.h"

  11. u16 led4pwmval=0;
  12.    
  13. int main(void)
  14. {               


  15.         delay_init();                     //延時(shí)函數(shù)初始化          
  16.         NVIC_Configuration();          //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
  17.         LED_Init();                             //LED端口初始化
  18.         KEY_Init();          //初始化與按鍵連接的硬件接口
  19.     Adc_Init();
  20. //        Hx711_Init();
  21.         OLED_Init();       
  22.         OLED_Clear();
  23.         TIM2_Int_Init(4999,71);  //500ms 1Mhz  0.005s
  24.     TIM4_Int_Init(899,0); //不分頻。PWM頻率=72000/(899+1)=80Khz  
  25.         //TIM5_Int_Init(4999,7199);//10Khz的計(jì)數(shù)頻率,計(jì)數(shù)到5000為500ms  



  26.                 OLED_ShowCHinese(18+10,0,2);/*測(cè)*/

  27.                 OLED_ShowCHinese(54+30,0,8);/*速*/          

  28.         OLED_ShowString(0,3,(unsigned char*)"speed",16);
  29.         OLED_ShowString(0,6,(unsigned char*)"light",16);

  30.                 BEEP=1;
  31.                 delay_ms(200);
  32.                 BEEP=0;
  33.                 delay_ms(200);

  34.         while(1)
  35.         {

  36. //       adcx=Get_Adc_Average(ADC_Channel_9,10);
  37. //        OLED_ShowNum(60,6,adcx,1,16);

  38.     light_change();
  39.         he_show();
  40.         TIM_SetCompare4(TIM4,led4pwmval);               
  41.                
  42.                
  43. }




  44. }
復(fù)制代碼


程序.7z

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


作者: YKL958    時(shí)間: 2021-10-21 18:37
有電路圖嗎?




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