亚洲春色中文字幕久久久-三上亚,91精品国产亚一区二区三区,久久久九色综合亚洲成色777,涩涩视频下载,国产午夜亚洲精品午夜鲁丝片,国产精品A一区二区三区腾讯导航,影音先锋色情AV在线看片,蜜臀国产在线视频,极品少妇高潮啪啪无码吴梦梦 ,精品人妻无码一区二区三区手机版

標(biāo)題: stm32f407-hcsr04超聲波 [打印本頁]

作者: YD1633732177    時(shí)間: 2020-6-3 14:25
標(biāo)題: 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               
                                //計(jì)數(shù)器清零,開始計(jì)數(shù)
                TIM_Cmd(TIM3, ENABLE);//開啟定時(shí)器        
        while(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1)  ==1);//等待echo->high
                    TIM_Cmd(TIM3, DISABLE);     //關(guān)閉定時(shí)器
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

299.03 KB, 下載次數(shù): 35, 下載積分: 黑幣 -5


作者: kcl21    時(shí)間: 2021-9-19 09:00
測(cè)試過嗎




歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1