Distance Meter
This meter was developed using Arduino Uno, HC-SR04 sensor and a 16X2 LCD display for displaying each measurement.
Bill of Materials
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
This is your diagram so that you follow step by step the project in its essence.
Assembling the Project
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
Mount what you completed in the previous step on your Arduino Uno.
Upload the Code
//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
For uploading the code, you should copy and paste the code in the previous step.
Enjoy Your Project
Enjoy your project by measuring distances with this amazing meter.