新手上路
- 积分
- 37
- 金钱
- 37
- 注册时间
- 2016-9-27
- 在线时间
- 14 小时
|
用根据红外测出来的数据,对PWM进行控制,程序只执行了if语句,距离再次减小时,PWM没停止
extern u8 TIM5CH1_CAPTURE_STA; //êäèë2¶»ñ×′ì¬
extern u32 TIM5CH1_CAPTURE_VAL; //êäèë2¶»ñÖμ
extern short temp1;
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
LED_Init(); //3õê¼»ˉLED
LCD_Init(); //3õê¼»ˉLCD½ó¿ú
Adc_Init();
TIM8_GPIO_Config();//3õê¼»ˉADC
TIM14_PWM_Init(20000-1,84-1);
GPIO_SetBits(GPIOF,GPIO_Pin_9 | GPIO_Pin_10);
TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1); //òÔ1MhzμÄÆμÂê¼Æêy
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Sensing Modules");
LCD_ShowString(30,70,200,16,16,"XXXX ");
POINT_COLOR=BLUE;//éèÖÃ×ÖìåÎaà¶é«
LCD_ShowString(30,170,300,16,16,"Ulterasonic: cm");
LCD_ShowString(30,210,300,16,16,"Ifared _dtc: cm"); //ÏèÔú1춨λÖÃÏÔê¾D¡êyμã
while(1)
{
ifared_dtc();//红外测距
if (temp1<15)
{
mode4(); //PWM停止
}
else if (temp1>15)
{
Tim8_Config(); //前进
}
delay_ms(10);
}
}
|
|