超声波模块使用说明书尊敬的客户:您好!感谢您选用本店的超声波测距模块,为了更快更好的使用本产品,请您仔细的阅读本使用说明书。一、超声波测距模块简介检测距离:5CM-5M分辨率:5MM数字电平信号,可直接接单片机,无需任何辅助电路,也无需单片机产生任何信号辅助,距离和模块输出信号脉冲长度成正比。尺寸:43.5*20.5毫米高度:13.8毫米二、超声波测距模块的引脚功能如上图所示:从左到右依次为 VCC、控制发射、接收信号(距离信号由此输出)、空脚、GND。(以上是正确顺序,模块上所标的不对,特此更正)三、测距方式: 通过单片机 i/o 口向模块控制信号接口发送一个>=10US 的高电平信号(启动测距功能),等待然后是检测输出信号,输出信号的高电平时间与距离成正比。然后根据高电平的时间便可计算出距离。示例程序:////////////////////////////////////////////////////////////////////////////////////PIC16F877 + DYP-ME007 + LCD03 example//Written October 2005 by Gerald Coe, using HITECH PIC16compiler////Note - assumes a 20MHz crystal, which is 5MHz timer clock//A 1:4 prescaler is used to give a 1.25MHz timer count (0.8uSper tick)////This code is Freeware - Use it for any purpose you like./////////////////////////////////////////////////////////////////////////////////#include
#include __CONFIG(0x3b32);#define trigRB0#define echoRB1void clrscn(void);// prototypesvoid cursor(char pos);void print(char *p);void setup(void);unsigned int get_srf04(void);char s[21];// buffer used to holdtext to printvoid main(void){unsigned int range;setup();// sets up thePIC16F877 I2C portclrscn();// clears the LCD03 displycursor(2);// sets cursor to 1st rowof LCD03sprintf(s,"SRF04 Ranger Test");// text, printed into ourbufferprint(s);// send it to the LCD03while(1) {// loop foreverrange = get_srf04();// get range from srf04(round trip flight time in 0.8uS units)cursor(24);// sets cursor to 2ndrow of LCD03sprintf(s,"Range = %dcm", range/72); // convert to cmprint(s);// send it to the LCD03cursor...