Distance Meter

by braulio777 in Circuits > Arduino

4796 Views, 83 Favorites, 0 Comments

Distance Meter

Arduino Distance Meter

This meter was developed using Arduino Uno, HC-SR04 sensor and a 16X2 LCD display for displaying each measurement.

Bill of Materials

20161226_190039.jpg
20161226_190043.jpg
20161226_190102.jpg
20161226_190116.jpg

1 Arduino Uno

1 HC-SR04 ultrasonic sensor

1 16x2 LCD Display

1 Arduino Uno Proto Shield

1 Headers

1 10k Ohm Square Cermet Potentiometer

1 USB 2.0 Cable

1 Enclosure for Arduino Boards

Schematic

Distance_meter.txt_schem.png

This is your diagram so that you follow step by step the project in its essence.

Assembling the Project

20161226_192458.jpg
20161226_192507.jpg
20161226_192512.jpg
20161226_193551.jpg
20161226_193615.jpg
20161226_193618.jpg

I installed the 16X2 LCD display into the Arduino PCB using the headers and also installed the HC-SR04 sensor. I used red and black heat shrink tube for connecting to +5V and GND respectively in this sensor while connecting trigPin to arduino pin 12 and echoPin to Arduino pin 13 for completing this operation.

Joining the Parts

20161227_105057.jpg
20161227_105101.jpg
20161227_105121.jpg
20161227_105138.jpg
20161227_105144.jpg

Mount what you completed in the previous step on your Arduino Uno.

Upload the Code

20161227_123544.jpg
20161227_123547.jpg

//Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 9, 5, 4, 3, 2);

#define trigPin 12

#define echoPin 13

int duration, Distance;

void setup() {

Serial.begin(9600);

pinMode(trigPin,OUTPUT);

pinMode(echoPin,INPUT);

lcd.begin(16,2);

lcd.setCursor(0,0);

lcd.print( "Distance:" );

}

void loop() {

digitalWrite(trigPin, HIGH);

delayMicroseconds(1000);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

Distance = (duration/2) / 29.1;

Serial.print(Distance);

Serial.println(" cm");

lcd.setCursor(0,1);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print(Distance);

lcd.print(" cm");

delay(500);

}

Code Uploaded

20161227_123809.jpg
20161227_124202.jpg

For uploading the code, you should copy and paste the code in the previous step.

Enjoy Your Project

20161227_124202.jpg

Enjoy your project by measuring distances with this amazing meter.