This project measures the distance of an object using the HC-SR04 ultrasonic sensor and displays the distance in centimeters on a 16×2 LCD. It works on the principle of ultrasonic sound wave reflection.
๐ง Components Required
-
Arduino UNO
-
Ultrasonic Sensor HC-SR04
-
16×2 LCD
-
10kฮฉ Potentiometer (for LCD contrast)
-
Breadboard
-
Jumper wires
-
USB cable
⚙️ Working Principle
-
The Trigger pin sends an ultrasonic pulse.
-
The pulse hits an object and reflects back.
-
The Echo pin receives the reflected signal.
-
Arduino calculates distance using time delay.
-
Distance is displayed on the LCD.
๐ Distance Formula:
๐ Circuit Connections
HC-SR04 → Arduino
| HC-SR04 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| Trig | D9 |
| Echo | D10 |
| GND | GND |
LCD → Arduino
| LCD Pin | Arduino Pin |
|---|---|
| RS | D7 |
| E | D6 |
| D4 | D5 |
| D5 | D4 |
| D6 | D3 |
| D7 | D2 |
| VSS | GND |
| VDD | 5V |
| V0 | Potentiometer |
| RW | GND |
๐ป Arduino Code
๐ Output
-
LCD displays real-time distance in centimeters
-
Measurement range: 2 cm to 400 cm
-
Accuracy: ±3 mm






0 comments:
Post a Comment