基于stm32f103超声波测距模块(LCD显示)
单片机源程序如下:
- #include "stm32f10x.h"
- #include "./usart/bsp_usart.h"
- #include "./lcd/bsp_ili9341_lcd.h"
- #include "./flash/bsp_spi_flash.h"
- #include "interface.h"
- #include "UltrasonicCtrol.h"
- unsigned char tick_5ms = 0;//5ms计数器,作为主函数的基本周期
- char dispBuff[100];
- int main(void)
- {
- delay_init();
- GPIOCLKInit();
- UltraSoundInit();
-
- //LCD 初始化
- ILI9341_Init ();
- /* USART config */
- USART_Config();
-
-
- ILI9341_GramScan ( 6 );
- ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH); /* 清屏,显示全黑 */
-
- while ( 1 )
- {
- tick_5ms++;
- if(tick_5ms >= 5)
- {
- GetDistanceDelay();
- tick_5ms = 0;
- }
- /*使用c标准库把变量转化成字符串*/
- sprintf(dispBuff,"juli : %.2d ",distance_cm);
- ILI9341_DispStringLine_EN(LINE(6),dispBuff); //第六行显示(dispBuff是字符串)
- Delayms(100);
-
- }
-
- }
- /* ------------------------------------------end of file---------------------------------------- */
复制代码
所有资料51hei提供下载:
基于stm32f103超声波测距模块(LCD显示).rar
(345.65 KB, 下载次数: 107)
|