Anecita, Latumbo is a distance-monitoring system that uses an ultrasonic sensor to detect objects and provide real-time visual and audio feedback. The project combines an HC-SR04 distance sensor with three indicator LEDs, a piezo buzzer, and a 20x4 LCD display to create an interactive proximity alert system.
This guide provides a complete parts list, wiring diagram, and step-by-step assembly instructions for building the project on an Arduino Uno. The included firmware handles sensor readings, distance calculations, and coordinated control of the LEDs, buzzer, and display to alert users when objects enter different distance zones.
Wiring diagram

Gather all the parts
Assemble it in 5 steps
1. Disconnect power first
Unplug USB while making every connection. Use jumper wires to join the shared 5V and GND connections.
- Do not connect 5V directly to GND; a short can damage the board.
2. Connect the three LEDs
Connect D2 through one 220 ohm resistor to the red LED long leg (anode). Connect D3 through a second resistor to the yellow or green LED long leg. Connect D4 through a third resistor to the blue or white LED long leg. Connect each short leg (flat side) to GND.
- Each LED needs its own resistor to prevent LED or board damage.
3. Connect the distance sensor
Follow the printed pin labels. VCC goes to 5V, GND to GND, TRIG to D6 (trigger pulse), and ECHO to D7 (return pulse).
- Aim the two round transducers at a flat object approximately 2 to 400 cm away. Measurements below 2 cm are unreliable.
4. Connect the passive piezo
Connect the signal lead to D9 and the other lead to GND. If marked plus and minus, use plus for D9 and minus for GND.
- This wiring is for a small passive piezo element
- not a high-current electromagnetic buzzer.
5. Connect the 20-column four-row LCD
Connect VCC to 5V, GND to GND, SDA to A4 (data), and SCL to A5 (clock). Use the labels on the backpack rather than assuming its pin order.
- The code automatically finds the I2C address. If the backlight works but text is invisible
- gently adjust the small contrast screw on the backpack.
Review all connections
1. Connections between "rred" and "Arduino"
2. Connections between "red" and "Arduino"
3. Connections between "ryellow" and "Arduino"
4. Connections between "yellow" and "Arduino"
5. Connections between "rblue" and "Arduino"
6. Connections between "blue" and "Arduino"
7. Connections between "buzzer" and "Arduino"
8. Connections between "sonar" and "Arduino"
9. Connections between "lcd" and "Arduino"
Deploy the firmware
#include <Arduino.h>
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
const byte RED = 2, YELLOW = 3, BLUE = 4;
const byte TRIG = 6, ECHO = 7, BUZZER = 9;
hd44780_I2Cexp lcd; // Automatically finds the LCD address and backpack wiring.
bool lcdReady = false;
char previous[4][21] = {};
void showLine(byte row, const char *text) {
char line[21];
memset(line, ' ', 20);
line[20] = '\0';
size_t length = strlen(text);
memcpy(line, text, length > 20 ? 20 : length);
if (lcdReady && strcmp(line, previous[row]) != 0) {
lcd.setCursor(0, row);
lcd.print(line);
strcpy(previous[row], line);
}
}
void setup() {
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(BUZZER, OUTPUT);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
digitalWrite(TRIG, LOW);
Serial.begin(9600);
lcdReady = (lcd.begin(20, 4) == 0);
if (!lcdReady) Serial.println(F("LCD not detected: check wiring and contrast"));
}
void loop() {
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
unsigned long duration = pulseIn(ECHO, HIGH, 30000UL);
float distance = duration / 58.0f;
bool valid = duration != 0 && distance >= 2 && distance <= 400;
bool far = valid && distance >= 20;
bool close = valid && distance <= 10;
bool closer = valid && distance > 10 && distance <= 15;
digitalWrite(RED, far);
digitalWrite(BLUE, close);
digitalWrite(YELLOW, closer);
if (close) tone(BUZZER, 4000);
else noTone(BUZZER);
char line[21];
if (valid) {
char number[10];
dtostrf(distance, 5, 1, number);
snprintf(line, sizeof(line), "Distance: %s cm", number);
} else strcpy(line, "Distance: no reading");
showLine(0, line);
showLine(1, !valid ? "Check sensor/target" : far ? "The Distance is far" :
close ? "The OBJECT is" : closer ? "Object is Closer" : "Between 15 and 20 cm");
showLine(2, close ? "TOO CLOSE" : "");
showLine(3, close ? "Buzzer: ON" : "Buzzer: OFF");
Serial.println(line);
delay(150); // HC-SR04 needs at least 60 ms between triggers.
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




