Take the distance reading and turn it into beep rate: slow far away, faster as you close in, solid at the stop point. Short to build, and it teaches you to turn a number into something a person can act on without looking at a screen. Averaging a few readings stops a single bad echo from making it stutter.
Every item is in the kit — nothing extra to buy.
All 24 parts in one box, with this project and 15 more to build from them.
One of each part. Packs (resistor assortment, jumper wires) already hold more than a single build needs. Backorder parts ship once they arrive — the kit above has every part boxed today. Delivery is free on orders AED 150.00+.
Written for the board in the kit. Copy it into the Arduino IDE; change the pin numbers if you wire it differently.
/*
07 — Parking assistant
Board: ESP32. Parts: HC-SR04, buzzer module, 3 x 1 kΩ from the resistor pack.
Wiring:
HC-SR04: VCC -> VIN (5 V), GND -> GND, TRIG -> GPIO 5
ECHO -> 1 kΩ -> GPIO 18, then two 1 kΩ in series from GPIO 18 -> GND
Buzzer: VCC -> 3V3, GND -> GND, IO -> GPIO 23 (active buzzer: HIGH = sound)
Distance becomes beep rate: slow far away, faster closing in, solid at the
stop line. Turning a number into something a person reacts to without a screen.
*/
const int TRIG_PIN = 5;
const int ECHO_PIN = 18;
const int BUZZER_PIN = 23;
const float STOP_CM = 15; // solid tone at or below this
const float FAR_CM = 120; // silent beyond this
float readCm() {
digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
unsigned long us = pulseIn(ECHO_PIN, HIGH, 30000UL);
return us == 0 ? -1 : us / 58.0;
}
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
// Average 3 readings — a single bad echo would make the beeps stutter.
float sum = 0; int n = 0;
for (int i = 0; i < 3; i++) { float d = readCm(); if (d > 0) { sum += d; n++; } delay(20); }
float cm = n ? sum / n : -1;
Serial.println(cm);
if (cm < 0 || cm > FAR_CM) { // nothing close: quiet
digitalWrite(BUZZER_PIN, LOW);
delay(100);
} else if (cm <= STOP_CM) { // stop line: solid
digitalWrite(BUZZER_PIN, HIGH);
delay(100);
} else { // beep, faster as it gets closer
int gap = map((int) cm, (int) STOP_CM, (int) FAR_CM, 60, 600); // ms between beeps
digitalWrite(BUZZER_PIN, HIGH); delay(40);
digitalWrite(BUZZER_PIN, LOW); delay(gap);
}
}
The DHT11 sends both temperature and humidity down a single data wire using its own timing protocol, so a library does the decoding for you. Wire three pins, install the…
Show live readings on the LCD and sound the buzzer when the room crosses a threshold you set. The interesting part is what happens at the boundary: a naive version chatt…
Send a pulse, time the echo, divide by two, convert to centimetres. Unlike an analog sensor this is a timing measurement, so you meet pulse timing and microsecond resolu…