Sie sind auf Seite 1von 4

16/12/2018 Simple ultrasonic range finder using arduino.

Circuit diagram, program and theory

Looking for Latest Electronics Project Kits? CLICK HERE (http://www.store.circuitstoday.com/)


(http://www.circuitstoday.com)

SPONSORED SEARCHES

Arduino Ultrasonic Range Finder PCB Schematic Circuit Design

LED Display Coding Tutorial Electronic Circuit

Ultrasonic range finder using arduino


(http://www.circuitstoday.com/ultrasonic-
rangefinder-using-arduino)
 praveen  June 19, 2014  7 Comments

Ada Promo Khusus desain pria banget bikin lu makin


Member beda bro

Ultrasonic range finder using arduino.


Ultrasonic range nder using 8051 mictrocontroller has been already published by me in this website. This time it is an ultrasonic range nder using arduino. HC-SR04
ultrasonic range nder module is used as the sensor here. The display consists of a three digit multiplexed seven segment display. This range nder can measure up to
200 cm and has an accuracy of 1cm. There is an option for displaying the distance in inch also. Typical applications of this range nder are parking sensors, obstacle
warning system, level controllers, terrain monitoring devices etc. Lets have a look at the HC-SR04 ultrasonic module rst.

HC SR04 ultrasonic module.

HC SR04 is an ultrasonic range nding module with an accuracy of 0.3cm. The sensing range of this module is from 2cm to 5 meter. Working current of this sensor is
15mA and the measuring angle is 15°. The photograph of front and back side of the HC-SR04 sensor is shown in the gure below.

(http://www.circuitstoday.com/wp-content/uploads/2014/05/HC-SR04-ultrasonic-range- nder.png)

HC-SR04 has four pins. Their names and functions are explained below.

Vcc: 5V supply voltage is given to this pin.


Trigger: A 10uS long pulse is given to this pin for triggering the transmission. Upon receiving a valid trigger pulse, the HR-SR04 issues eight 40KHz pulses. Time
taken by these pulses to re ect back is measured and the distance is calculated from it.
Echo: At this pin the HC-SR04 outputs a signal whose high time is proportional to the range.

http://www.circuitstoday.com/ultrasonic-rangefinder-using-arduino 1/11
16/12/2018 Simple ultrasonic range finder using arduino. Circuit diagram, program and theory

Ground : Ground is connected to this pin.


The timing diagram of  HC-SR04 is shown in the gure below.

(http://www.circuitstoday.com/wp-content/uploads/2014/05/HC-SR04-timing-
diagram.png)Circuit diagram.

Full circuit diagram of the ultrasonic range nder using arduino is shown in the gure below.

(http://www.circuitstoday.com/wp-content/uploads/2014/05/ulrasonic-range- nder-using-arduino.png)

Trigger pin of the ultrasonic range nder module is connected to digital pin 0 of the arduino. Echo pin of the ultrasonic module is connected to the digital pin 13 of the
arduino. SPDT switch S1 is used to select the unit of the measurement shown in the display. Pole of the SPDT switch S1 is connected to digital pin 4 of the arduino. If
digital pin 4 is held high, the output will be in centimeters and if the digital pin 4 is held low, the output will be in inches. Digit driver transistor Q1, Q2 and Q3 of the
arduino are interfaced to digital pins 1, 2 and 3 of the arduino. Multiplexed segments a to dp are interfaced to digital pins 5 to 12 of the arduino. The arduino board can
be powered through the +9V jack given on the board. 5V supply needed in some other parts of the circuit can be obtained from the 5V source available in the arduino
board. Resistors R9, R10 and R11 limits the base current of the corresponding transistors. 330 ohm resistors R1 to R8 limits the current through the corresponding
segments. Pin out of an E1-3056ASR1 three digit MUX seven segment display in shown in the gure below.

http://www.circuitstoday.com/ultrasonic-rangefinder-using-arduino 2/11
16/12/2018 Simple ultrasonic range finder using arduino. Circuit diagram, program and theory

(http://www.circuitstoday.com/wp-content/uploads/2014/05/3-digit-multiplexed-display-pinout.png)

Program.

#include <NewPing.h>
#define trig 0
#define echo 13
#define maximum 200
int a;
int unit;
int usec;
int input=4;
int disp1=1;
int disp2=2;
int disp3=3;
int segA=5;
int segB=6;
int segC=7;
int segD=8;
int segE=9;
int segF=10;
int segG=11;
int segDP=12;

About the program.

For communicating with the ultrasonic range nder module, library function <NewPing.h> is used. The job of sending the 10uS trigger pulse, waiting for the echo and
measuring the width of the echo etc are done by the library function. Just one line of code usec=sonar.ping()will make the arduino to do all the jobs said above and
 the width of the echo pulse  in micro seconds will be stored in the variable usec. Dividing the pulse width in uS by 58 will give the distance in cm and dividing the pulse
width in uS by 148 will give the distance in inch. An “if – else” loop is used for selecting the unit according to the position of the SPDT selector switch(S1). Displaying
the distance on the three digit 7 segment display is done by the method used in the earlier project Voltmeter using arduino (http://www.circuitstoday.com/voltmeter-
using-arduino).

The <NewPing.h> library can be downloaded from here: NewPing_v1.5 (http://www.circuitstoday.com/wp-content/uploads/2014/05/NewPing_v1.5.zip). Download


this zip le, unzip it into a folder, name it NewPing or something and copy it into the …….Program Files/Arduino/Library folder.

Ultrasonic range finder with LCD display.

This is just the LCD version of the above project. The working principle of this circuit is same as that of the  7-segment LED version. Only change is on the display
device. In this circuit a 16×2 LCD display is used for displaying the distance. The distance in cm and inch are displayed simultaneously on the LCD screen. Before
attempting the LCD version, go through this article: Interfacing LCD to Arduino (http://www.circuitstoday.com/interfacing-lcd-to-arduino). Circuit diagram of the LCD
range nder is shown below.

Circuit diagram: LCD range finder.

http://www.circuitstoday.com/ultrasonic-rangefinder-using-arduino 3/11
16/12/2018 Simple ultrasonic range finder using arduino. Circuit diagram, program and theory

(http://www.circuitstoday.com/wp-content/uploads/2014/05/ultrasonic-range- nder-LCD.png)

Program: LCD range finder.

lcd.begin(16,2);

}
void loop()
{ lcd.clear();
lcd.setCursor(2,0);
lcd.print("Range Finder");
usec=sonar.ping();
cm=usec/58;
inch=usec/58/2.54;
lcd.setCursor(0,1);
lcd.print(cm);
lcd.print("cm");
lcd.setCursor(7,1);
lcd.print(inch);
lcd.print("inch");
delay(250);

SPONSORED SEARCHES

Arduino Ultrasonic Range Finder Circuit Design

LED Display Meter Measurement

Tags: ultrasonic range nder (http://www.circuitstoday.com/tag/ultrasonic-range- nder), ultrasonic range nder (http://www.circuitstoday.com/tag/ultrasonic-
range nder), ultrasonic range nder LCd (http://www.circuitstoday.com/tag/ultrasonic-range nder-lcd)
Categories: Arduino (http://www.circuitstoday.com/category/arduino)

 Previous post (( Next post 


hh

tt

http://www.circuitstoday.com/ultrasonic-rangefinder-using-arduino 4/11

Das könnte Ihnen auch gefallen