|
單片機(jī)源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "usart.h"
- #include "exti.h"
- #include "beep.h"
- #include "timer.h"
- #include "wave.h"
- #include "sys.h"
- #include "lcd.h"
- #include "sg.h"
- u16 num,l=0,h=0;
-
- void kongzhi()
- {
- if(h>=2)
- {
- sg=1;delay_ms(1);
- sg=0;delay_ms(1);
-
- }
- else if(h<1)
- {
- sg=0;delay_ms(1);
- sg=1;delay_ms(1);
- }
- }
- int main(void)
- {
-
- delay_init(); //延時(shí)函數(shù)初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
- uart_init(115200); //串口初始化為115200
- LED_Init(); //初始化與LED連接的硬件接口
- BEEP_Init(); //初始化蜂鳴器端口
- KEY_Init(); //初始化與按鍵連接的硬件接口
- LCD_Init();
- //EXTIX_Init(); //外部中斷初始化
- //LED0=0; //點(diǎn)亮LED0
- Timer_SRD_Init(5000,7199);
- Wave_SRD_Init();
- LCD_Clear(WHITE);//清屏函數(shù)
- while(1)
- {
- h=num/10000;
- l=num/100%100;
- LCD_ShowxNum(0,12,h,1,16,1);//顯示數(shù)值
- LCD_ShowChar(9,12,0x2e,16,0);
- LCD_ShowxNum(12,12,l,2,16,1);//顯示數(shù)值
- LCD_ShowString(30,12,12,12,16,"m");
- LED1=!LED1;
- delay_ms(200);
- sg=0;
- kongzhi();
- LCD_Clear(WHITE);//清屏函數(shù)
- Wave_SRD_Strat();
- num=EXTI9_5_IRQHandler();//讀取數(shù)值
- }
- }
復(fù)制代碼
全部資料51hei下載地址:
超聲波模塊程序_STM32F103ZET6.7z
(228.32 KB, 下載次數(shù): 104)
2019-1-3 02:03 上傳
點(diǎn)擊文件名下載附件
|
-
-
stm32_F1 超聲波加LCD.rar
2019-1-2 16:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
3.39 MB, 下載次數(shù): , 下載積分: 黑幣 -5
stm32f1超聲波測距LCD顯示
評(píng)分
-
查看全部評(píng)分
|