|
話不多說(shuō),自己下載研究。用的STM32F103C8T6,引腳自己打開(kāi)程序里面看。串口輸出四路超聲波檢測(cè)結(jié)果,單位cm。
單片機(jī)源程序如下:
- /**
- ******************************************************************************
- * @file main.c
- * @author fire
- * @version V1.0
- * @brief 串口中斷接收測(cè)試
- */
-
- #include "stm32f10x.h"
- #include "bsp_usart1.h"
- #include "stdio.h"
- #include "timer2_cap.h"
- #include "UltrasonicWave.h"
- #include "delay.h"
- /**
- * @brief 主函數(shù)
- * @param 無(wú)
- * @retval 無(wú)
- */
- 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的頻率計(jì)數(shù)
- 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**********************/
復(fù)制代碼
所有資料51hei提供下載:
STM32F103C8T6四通道超聲波檢測(cè)(串口).rar
(339.43 KB, 下載次數(shù): 74)
2018-4-9 00:49 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|