|
涉及红外车速检测,光照检测,以及pwm调光- #include "sys.h"
- #include "delay.h"
- #include "key.h"
- #include "led.h"
- //#include "usart.h"
- #include "hx711.h"
- #include "exti.h"
- #include "timer.h"
- #include "oled.h"
- #include "adc.h"
- u16 led4pwmval=0;
-
- int main(void)
- {
-
- delay_init(); //延时函数初始化
- NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- LED_Init(); //LED端口初始化
- KEY_Init(); //初始化与按键连接的硬件接口
- Adc_Init();
- // Hx711_Init();
- OLED_Init();
- OLED_Clear();
- TIM2_Int_Init(4999,71); //500ms 1Mhz 0.005s
- TIM4_Int_Init(899,0); //不分频。PWM频率=72000/(899+1)=80Khz
- //TIM5_Int_Init(4999,7199);//10Khz的计数频率,计数到5000为500ms
- OLED_ShowCHinese(18+10,0,2);/*测*/
- OLED_ShowCHinese(54+30,0,8);/*速*/
- OLED_ShowString(0,3,(unsigned char*)"speed",16);
- OLED_ShowString(0,6,(unsigned char*)"light",16);
- BEEP=1;
- delay_ms(200);
- BEEP=0;
- delay_ms(200);
- while(1)
- {
- // adcx=Get_Adc_Average(ADC_Channel_9,10);
- // OLED_ShowNum(60,6,adcx,1,16);
- light_change();
- he_show();
- TIM_SetCompare4(TIM4,led4pwmval);
-
-
- }
- }
复制代码
|
-
-
程序.7z
247.46 KB, 下载次数: 10, 下载积分: 黑币 -5
|