基于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)
2018-7-25 00:25 上傳
點擊文件名下載附件
|