Hi guys in this instructables we will make a project which can tell the distance of nearby object and print it on the lcd display attached to arduino uno. This project can be very useful when creating a autodriving robot car or the Projects which requires measuring the distance of a obstacle or object. So basically ultrasonic sensor we will be using to read the distance of object from the sensor and this data will be read by arduino from ultrasonic sensor and then arduino will print this data on 1602 LCD display.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Things You Need
Step 2: Circuit Diagram
The circuit diagram for arduino and ultrasonic sensor is shown above to measure the distance. In circuit connections Ultrasonic sensor module’s “trigger” and “echo” pins are directly connected to pin 18(A4) and 19(A5) of arduino. A 16x2 LCD is connected with arduino in 4-bit mode. Control pin RS, RW and En are directly connected to arduino pin 2, GND and 3. And data pin D4-D7 is connected to 4, 5, 6 and 7 of arduino.
Step 3: Working
we need to trigger the ultrasonic sensor module to transmit signal by using arduino and then wait for receive ECHO. Arduino reads the time between triggering and Received ECHO. We know that speed of sound is around 340m/s. so we can calculate distance by using given formula:
Distance= (travel time/2) * speed of sound
Where speed of sound around 340m per second.
A 16x2 LCD is used for displaying distance.
Step 4: Code
Please copy the following code & Upload it to your arduino Board ;
#define trigger 18
#define echo 19
lcd.print(" Ultra sonic");
Step 5: Measuring Distance in Real Time
So after connecting everything together & uploading code to arduino board and if everything is fine then if we put a object in front of ultrasonic sensor we can see the distance of object in lcd display as you can see different different distance values in the images. So have fun using ultrasonic sensor with arduino and measure distance with arduino.