基于单片机的超声波测距仪的设计摘要 本设计介绍了基于单片机设计的超声波测距仪的原理:由STC89C51控制定时器产生超声波脉冲并计时,计算超声波自发射至接收的往返时间,从而得到测量距离。并且在数据处理中设置了距离的高低限,用四位LED数码管显示距离,同时当超过限值时用蜂鸣器实现报警。此超声波测距系统是基于51单片机,由HC-SR04超声波测距模块,数码管,阻容元件,蜂鸣器等组成,系统带有距离报警功能,报警通过蜂鸣器和LED做出反应,并且系统报警距离可通过按键随时更改。超声波测距模块可提供2cm—400cm的非接触式感测功能,测距精度可达到3mm,模块包括超声波发射器,接收器以及控制电路。本作品成本低,可抗性相对较高,测得的距离能够清楚稳定的显示在四位数码管上,且小巧轻便,应用起来比较方便。关键词:STC89C51;超声波;测距Ultrasonic rangefinder design based on single chip microcomputerAbstractThis design describes the chip design based on the principle of ultrasonic range finder:when STC89C51 controlled the timer that generates an ultrasonic pulse and timing ,calculated the round-trip time from the ultrasonic transmitter to the receiver , resulting in the measured distance. In the data processing and set high and low limit of distance, with four LED digital display distance, but when the limit is exceeded an alarm buzzer. This ultrasonic ranging system is based on 51 single, the HC-SR04 ultrasonic ranging module, LED, resistive and capacitive components, buzzer, etc., with distance alarm system, alarm buzzer and respond by LED, and the system can be changed at any time from the alarm by pressing a button. Ultrasonic Ranging Module provides 2cm-400cm non-contact sensing capabilities, ranging accuracy can reach 3mm, module comprises an ultrasonic transmitter, a receiver and a control circuit. The work of low cost, relatively high resistance, the measured distance can be displayed on a clear and stable four digital tube, and the compac...