欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
stm32f407-hcsr04超聲波
[打印本頁]
作者:
YD1633732177
時間:
2020-6-3 14:25
標題:
stm32f407-hcsr04超聲波
#include "stm32f4xx.h"
#include "usart.h"
#include "delay.h"
#include "voice.h"
int main()
{
u16 times,i=5,all;
long long truth;
int distance=0;
uart_init(115200);//初始化串口波特率為115200
voice_int();
delay_init(168);
while(1)
{
for(i=0;i<5;i++)
{
printf("2\r\n");
GPIO_SetBits(GPIOB, GPIO_Pin_0); //給20um的高電平
delay_ms(10);
GPIO_ResetBits(GPIOB, GPIO_Pin_0);
printf("3\r\n");
TIM3->CNT = 0;
while(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) ==0); //等待echo->low
//計數器清零,開始計數
TIM_Cmd(TIM3, ENABLE);//開啟定時器
while(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) ==1);//等待echo->high
TIM_Cmd(TIM3, DISABLE); //關閉定時器
printf("5\r\n");
times = TIM_GetCounter(TIM3);
distance = (times*340)/200; //(1/200000)*344/2=0.00085m
all+=distance;
printf("************");
}
truth = all/5;
all=0;
printf("距離為cm:%lld\r\n",truth);
}
}
super voice.7z
2020-6-5 04:19 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
299.03 KB, 下載次數: 35, 下載積分: 黑幣 -5
作者:
kcl21
時間:
2021-9-19 09:00
測試過嗎
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1