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.
Add kit to cartOption 2 — Individual components
₹1,292The full parts list is ₹1,292 for all 8 items. Add them all at once, or pick single items from the list below.
- Arduino Uno R3 Compatible Board with USB CableCB-UNO-R3₹499Add to cart
- HC-SR04 Ultrasonic Distance SensorCS-HCSR04₹79Add to cart
- 0.96 inch OLED Display 128×64 I2C (SSD1306)CD-OLED-096₹199Add to cart
- LED Assortment Pack 100 Pieces (5 Colours)CA-LED-PACK₹79Add to cart
- Resistor Assortment Pack 600 PiecesCA-RES-PACK₹149Add to cart
- Active and Passive Buzzer PairCA-BUZZ₹49Add to cart
- 830 Point Solderless BreadboardCA-BB-830₹89Add to cart
- Jumper Wire Set 120 Pieces (M-M, M-F, F-F)CA-JUMPER-120₹149Add to cart
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.