标题: HR-SR04超声测距stm32源程序 [打印本页]

作者: 00000a    时间: 2019-5-18 18:42
标题: HR-SR04超声测距stm32源程序
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "hc.h"
int main(void)
{               
         u8 t=0;
    float length;
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
        delay_init();                     //延时函数初始化         
        uart_init(115200);         //串口初始化为115200
    HC_Init();



  while(1)
        {
                length = HcGetLength();
         printf("距离为:%.3f",length);
         printf("cm/n");



        }         
}


超声测距.PNG (78.35 KB, 下载次数: 35)

超声测距.PNG

超声测距-STM32.7z

185.72 KB, 下载次数: 27, 下载积分: 黑币 -5






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1