stm32四路超聲波檢測
單片機源程序如下:
- /**
- ******************************************************************************
- * @file main.c
- * @author fire
- * @version V1.0
- * @brief 串口中斷接收測試
- */
-
-
- #include "stm32f10x.h"
- #include "bsp_usart1.h"
- #include "stdio.h"
- #include "timer2_cap.h"
- #include "UltrasonicWave.h"
- #include "delay.h"
- /**
- * @brief 主函數
- * @param 無
- * @retval 無
- */
- int main(void)
- {
- unsigned char count=0;
- delay_init();
- /* USART1 配置模式為 115200 8-N-1,中斷接收 */
- USART1_Config();
-
- NVIC_Configuration();
-
- TIM2_Cap_Init(0xffff,72-1); //以1Mhz的頻率計數
- UltrasonicWave_Configuration();
-
- while(1)
- {
- switch(count)
- {case 0:UltrasonicWave_StartMeasure();
- count=1;
- break;
- case 1:UltrasonicWave_StartMeasure2();
- count=2;
- break;
- case 2:UltrasonicWave_StartMeasure3();
- count=3;
- break;
- case 3:UltrasonicWave_StartMeasure4();
- count=0;
- break;
- }
-
- printf("1:%d|2:%d|3:%d|4:%d\n",tempup1,tempup2,tempup3,tempup4);
- delay_ms(500);
- if(tempup1<=300)
- {
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
-
- }
- else
- {
- delay_ms(1000);
- }
- }
- }
- /*********************************************END OF FILE**********************/
復制代碼
所有資料51hei提供下載:
STM32F103C8T6四通道超聲波檢測.7z
(181.8 KB, 下載次數: 129)
2018-12-19 15:11 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|