Community project

Anecita, Latumbo

Photo of Anecita, Latumbo
Generated with AI

Jeslaine Anecita

Published December 1, 2026

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

Wiring diagram for Anecita, Latumbo
Loading diagram…

Gather all the parts

QtyComponent
1

LED

Red

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

LED

Yellow (or green)

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

LED

Blue (or white)

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

220 ohm

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

220 ohm

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

220 ohm

Through-hole resistor (current-limiting in series with an LED)

1

HC-SR04

HC-SR04 ultrasonic distance sensor module with separate 40 kHz transmitter and receiver transducers, measuring 2 to 400 cm. A 10 us pulse on TRIG starts a measurement and ECHO stays high for the echo's round-trip time. This HC-SR04+ board runs from 3.3 V or 5 V.

1

Piezo Buzzer

Small passive piezo buzzer (TDK PS1240) for beeps, tones and alerts. It has no built-in oscillator, so drive one lead with a 3-30 V square wave from a microcontroller pin using tone() or PWM and connect the other lead to ground. It is loudest around 4 kHz and works from about 2 to 10 kHz; driving both leads in antiphase roughly doubles the volume.

1

I2C 20x4 Arduino LCD Display Module

20x4 character LCD with I2C interface, white text on blue backlight, adjustable contrast. Operates at 5V or 3.3V; reduces pin usage to 2 lines (SDA/SCL).

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"

FunctionrredArduino
digitalP1GPIO 2
digitalP2 → LED ANODEEXT

2. Connections between "red" and "Arduino"

FunctionredArduino
groundGNDGND

3. Connections between "ryellow" and "Arduino"

FunctionryellowArduino
digitalP1GPIO 3
digitalP2 → LED ANODEEXT

4. Connections between "yellow" and "Arduino"

FunctionyellowArduino
groundGNDGND

5. Connections between "rblue" and "Arduino"

FunctionrblueArduino
digitalP1GPIO 4
digitalP2 → LED ANODEEXT

6. Connections between "blue" and "Arduino"

FunctionblueArduino
groundGNDGND

7. Connections between "buzzer" and "Arduino"

FunctionbuzzerArduino
pwmSIGGPIO 9
groundGNDGND

8. Connections between "sonar" and "Arduino"

FunctionsonarArduino
digitalTRIGGPIO 6
digitalECHOGPIO 7
powerVCC5V
groundGNDGND

9. Connections between "lcd" and "Arduino"

FunctionlcdArduino
powerVCC5V
groundGNDGND
i2cSDAGPIO 18
i2cSCLGPIO 19

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.

Open in Schematik