Ultrasonics Sensor
In this tutorial I will be measuring distance with an ultrasonic sensor.
Supplies
Arduino uno board
Ultrasonic sensor
Jumper wires
Ultrasonic sensor
Jumper wires
The Setup and Sensor Data
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.
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!
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
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.