Distance Measuring Device
by callmeappytechie in Circuits > Arduino
3424 Views, 41 Favorites, 0 Comments
Distance Measuring Device
Hey, Guys, I'm Sridhar Janardhan back with another tutorial.This time I am going to teach you how to create your own distance measuring instrument under 10$.I have tried my best to keep this ibles very simple so even a beginner can crack it down.This ibles needs a sensor called ultrasonic sensor whose operation will be explained in the later part of the ibles.So now let's start to gather the components.
Components Required:
The components required for this tutorials are:
- Arduino Uno
- Jumper wire
- Ultrasonic sensor
- LCDI2cBreadboard
HC-05 Ultrasonic Sensor:
The HC-05 Ultrasonics sensor is a device that is designed to measure the distance of an obstacle placed in front of them.it has two eye-like things the echo and trig.The echo pin emits a wave that travels through the medium and reflects back as soon as it hits the obstacles.The reflected wave triggers the trig pin, The time taken between the emitting and triggering the trig pin is calculated to estimate the distance between the sensor and the object.
Pin description of the HC-0s sensor:
- TRIG pin: This pin triggers the sensor and sends a control signal indicating the conveying of the objects.
- VCC pin: The positive power supply is given to this pin.
- GND pin: the Grounded power supply is given to this pin.
- ECHO pin: The pin that is used to send the wave into the medium
Pin connection as follows:
- TRIG pin: digital pin 13
- ECHO Pin: digital pin 12
- VCC pin: Positive railing of the breadboard
- GND pin: Negative railing of the breadboard
Let's now connect the LCD.
Connecting LCD:
I have soldered I2C TO lCDto make the connection easy.
To know the tutorial on how to connect I2C to LCD please click here
The connection of LCD is as follows:
- The SDA pin to Arduino analog pin A0.
- The SDL pin to Arduino analog pin A1.
- The VCC pin to the positive railing of the breadboard.
- The GND pin to the negative railing of the breadboard.
Let's get into coding
Coding
#include
LiquidCrystal_I2C lcd(0x3f, 16, 2);
void setup() {
lcd.begin();
Serial.begin(115200);
} void loop() {
lcd.setCursor(0, 0);
lcd.print("time: ");
lcd.print(duration);
lcd.print(" us ");
lcd.setCursor(0, 1);
if( duration > 38000 ) {
lcd.println("out of reach ");
} else {
lcd.print("dist: ");
lcd.print(distance);
lcd.println(" cm "); }
}
}