基于单片机多路超声波测距显示系统设计(毕设课设)
用了四路超声波,可以同时测量四个方向的距离,可以用在避障上或者其他地方,这里是我帮他们写的一个用在房屋面积测量上,并且显示在12864上当测试距离超了的时候他会显示“超”,附上电路图,容易看,不局限4路还可以更多。
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
//引脚定义
sbit Trig1 = P2 ^ 1; //
sbit Ecno1 = P2 ^ 0; //
sbit Trig2 = P3 ^ 2; //
sbit Ecno2 = P3 ^ 3; //
sbit Trig3 = P1 ^ 2; //
sbit Ecno3 = P1 ^ 3; //
sbit Trig4 = P3 ^ 0; //
sbit Ecno4 = P3 ^ 1; //
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
#define LCD_data P0 //数据口
sbit LCD_RS = P3^5; //寄存器选择输入
sbit LCD_RW = P3^6; //液晶读/写控制
sbit LCD_EN = P3^4; //液晶使能控制
sbit LCD_PSB = P3^1; //串/并方式控制
sbit wela = P2^6;
sbit dula = P2^7;
// 函数声明
void Write_char(uchar dat);
bit lcd_busy();
void Lcd_init(void);
void LCD_Write_string(uchar *str);
void LCD_set_xy( unsigned char x, unsigned char y );
void StartModule() ;
void Clr_Scr();
unsigned char code num[]={"0123456789 :."};
unsigned char code table1[]={"前方距离:"};
unsigned char code table2[] ={"后方距离:"};
unsigned char code table3[] ={"左方距离:"};
unsigned char code table4[] ={"右方距离:"};
unsigned char code M[] = {"CM"};
unsigned int time1=0;
unsigned int time2=0;
unsigned int time3=0;
unsigned int time4=0;
【资源下载】下载地址如下(893):https://docs.qq.com/doc/DTlRSd01BZXNpRUxl