标题:
stm32f1超声波测距+LCD显示代码
[打印本页]
作者:
李清波8
时间:
2019-1-2 16:11
标题:
stm32f1超声波测距+LCD显示代码
单片机源程序如下:
#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(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
LED_Init(); //初始化与LED连接的硬件接口
BEEP_Init(); //初始化蜂鸣器端口
KEY_Init(); //初始化与按键连接的硬件接口
LCD_Init();
//EXTIX_Init(); //外部中断初始化
//LED0=0; //点亮LED0
Timer_SRD_Init(5000,7199);
Wave_SRD_Init();
LCD_Clear(WHITE);//清屏函数
while(1)
{
h=num/10000;
l=num/100%100;
LCD_ShowxNum(0,12,h,1,16,1);//显示数值
LCD_ShowChar(9,12,0x2e,16,0);
LCD_ShowxNum(12,12,l,2,16,1);//显示数值
LCD_ShowString(30,12,12,12,16,"m");
LED1=!LED1;
delay_ms(200);
sg=0;
kongzhi();
LCD_Clear(WHITE);//清屏函数
Wave_SRD_Strat();
num=EXTI9_5_IRQHandler();//读取数值
}
}
复制代码
全部资料51hei下载地址:
超声波模块程序_STM32F103ZET6.7z
(228.32 KB, 下载次数: 104)
2019-1-3 02:03 上传
点击文件名下载附件
下载积分: 黑币 -5
stm32_F1 超声波加LCD.rar
2019-1-2 16:09 上传
点击文件名下载附件
下载积分: 黑币 -5
3.39 MB, 下载次数: , 下载积分: 黑币 -5
stm32f1超声波测距LCD显示
作者:
孟榜鑫
时间:
2019-3-31 15:26
能用吗
作者:
环环紧扣
时间:
2020-3-3 11:12
需要用到,麻烦了
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1