Three builds from one HC-SR04 — a digital distance meter in centimetres and inches, a parking assistant with safe/warning/stop zones, and an obstacle detector whose beep speeds up as you close in.
What is inside
Live distance in cm and inches on the OLED, updating every second, with OUT OF RANGE when nothing is there.
Zones the distance into safe, warning, danger and stop, with the beep rate and traffic lights changing per zone.
Written for navigation aids: CLEAR PATH, OBSTACLE AHEAD and STOP, with the buzzer tightening as the obstacle nears.
Circuit connections
| Connection | Arduino pin |
|---|---|
| HC-SR04 Trig | D9 |
| HC-SR04 Echo | D10 |
| Traffic light red / yellow / green | D4 / D5 / D6 |
| Buzzer signal | D8 |
| OLED SDA / SCL | A4 / A5 |
| Module power | 5V + GND |
Bench note: Readings jump about under 3 cm and past 400 cm. Clamp the range in software before you display it, or the parking zones will flicker.
Libraries used
Wire.hAdafruit_GFX.hAdafruit_SSD1306.hGet the parts
Two ways to build this, and you can choose either. Take the complete kit in one box, or buy only the individual components you are missing. Both use the normal shop cart.
Option 1 — Complete kit
₹999eARgle Mini Beginner Kit — everything needed, boxed, with the quick-start card and reference sketches.
Enquire to orderOption 2 — Individual components
₹781Live prices from our partner Robolark: ₹781 for 6 of 9 parts in stock. Add them all at once, or pick single items from the list below.
Add all 6 components- Uno R3-Microcontroller (ATmega328p)-Arduino CompatibleR-0007₹380Add to Parts Box
- Ultrasonic Sensor-HC-SR04R-0377₹86Add to Parts Box
- Oled Display - 4 pin (0.96 Inch)R-0036₹200Add to Parts Box
- Red LED-5mm (Pack of 5)R-0535₹5Out of stock
- Green LED - 5mm (Pack of 5)R-0364₹5Out of stock
- Resistor Box- AssortmentR-0541₹80Add to Parts Box
- Buzzer 5VR-0273₹15Add to Parts Box
- MB-102 Solderless Breadboard - 830 Tie PointsR-0204₹69Out of stock
- Jumper Wires - Male to Male × 2R-0457₹20Add to Parts Box
Already own the board or the display? Skip them — the sketches do not care where the parts came from.
From the bench
Source code
Every sketch on this page is open source. Clone it, change it, break it, tell us what you learned.
Want to be taught this, not just handed the code?
We run this as a mentor-led session for schools, colleges and individual learners, online or at our centre. Tell us what you want to build.