Ultrasonics Sensor

by chanidu1214 in Circuits > Arduino

551 Views, 1 Favorites, 0 Comments

Ultrasonics Sensor

Screenshot_20200323_205146.jpg
In this tutorial I will be measuring distance with an ultrasonic sensor.

Supplies

Arduino uno board
Ultrasonic sensor
Jumper wires

The Setup and Sensor Data

Screenshot_20200323_205736.jpg
Screenshot_20200323_201208.jpg
Connect the vcc pin of the ultrasonic sensor to 5v of the arduino board.
GND pin of the sensor to GND of the arduino board.
Trig pin to pin2 of arduino and echo pin to pin4 of arduino.

The Code As Always!

sketch_mar23a _ Arduino 1.8.1 3_23_2020 7_47_10 PM.png
sketch_mar23a_ultrasonic_ _ Arduino 1.8.1 3_23_2020 8_02_19 PM.png
This code will print the distance between the ultrasonic sensor and the object in front of it. The result will be printed in the serial monitor.

The Best Part

IMG_20200323_195937.jpg
COM15 3_23_2020 8_02_41 PM.png
Now you can measure distances upto 4 metres and it will be printed in the serial monitor(ctrl + shift + M or go to tools and double click on serial monitor). You can even connect a lcd and print the distance in it.