使用proteus仿真STM32超声波SRF04测距!Code+Proteus

您所在的位置:网站首页 手机测距仪是干嘛的 使用proteus仿真STM32超声波SRF04测距!Code+Proteus

使用proteus仿真STM32超声波SRF04测距!Code+Proteus

2024-07-12 15:17| 来源: 网络整理| 查看: 265

本贴使用Proteus8.10,如低版本打不开可自行根据原理图绘制(很简单) 单片机型号为:stm32f103系列 使用timer3。运行稳定,示数距离有偏差,可在源程序处更改。 如有问题,评论区留言,看到回~

在这里插入图片描述 在这里插入图片描述

#include "sys.h" #include "delay.h" #include "led.h" #include "key.h" #include "timer.h" int main(void) { float SRF04_Value = 123.45; uint8_t adcxxx[3] = {0, 0, 0}; HAL_Init(); Stm32_Clock_Init(RCC_PLL_MUL9); delay_init(72); LCD_init(); SRF04_init(); TIM3_Init(1000-1, 72-1); while(1) { SRF04_Value = Hcsr04GetLength(); adcxxx[0] = (uint16_t)SRF04_Value / 100 + 48; adcxxx[1] = (uint16_t)SRF04_Value % 100 / 10 + 48; adcxxx[2] = (uint16_t)SRF04_Value % 100 % 10 + 48; LCD_write_string(1, 0, "Distance:"); LCD_write_string(11, 0, (char*)adcxxx); } }

资源下载链接



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3