Community project

Calde, Flores

Photo of Calde, Flores
Generated with AI

Rey Jolar Flores

Published December 4, 2026

Calde, Flores is a distance monitoring system that uses an ultrasonic sensor to detect how far an object is from the device, then displays the measurement on an LCD screen and indicates the distance range with colored LEDs and audio feedback. The system triggers a buzzer and lights up different LEDs based on whether an object is far (green), medium (yellow), or close (red).

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, LCD display updates, and LED/buzzer control logic. Builders will learn how to integrate an I2C LCD display, work with ultrasonic distance sensing, and coordinate multiple output indicators.

Wiring diagram

Wiring diagram for Calde, Flores
Loading diagram…

Gather all the parts

QtyComponent
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

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).

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

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

330 ohm, 1/4 W

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

1

Resistor

330 ohm, 1/4 W

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

1

Resistor

330 ohm, 1/4 W

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

Assemble it in 5 steps

1. Prepare the parts with USB unplugged

Use the Uno R3, HC-SR04, 20x4 I2C LCD, passive piezo buzzer, red/yellow/blue LEDs, and three 330 ohm quarter-watt resistors. Green can replace yellow and white can replace blue. Use jumper wires for the connections.

  • Unplug USB before changing wires. Every LED needs its own resistor or it and the Uno output can be damaged.

2. Connect the distance sensor

Connect VCC to Uno 5V and GND to Uno GND. Connect TRIG to D7 (measurement trigger), and ECHO to D8 (distance timing). Read the printed pin labels, not the apparent left-to-right position.

3. Connect the LCD

Connect VCC to 5V, GND to GND, SDA to A4 (data), and SCL to A5 (clock). The firmware automatically finds the I2C backpack address and pin mapping.

  • If the backlight lights but text is invisible, gently turn the small contrast adjustment on the back of the LCD.

4. Connect the three indicator lights

Connect D2 through r_red to the red LED long leg (anode). Connect D3 through r_yellow to the yellow LED long leg. Connect D4 through r_blue to the blue LED long leg. All three short legs (cathodes, flat edge of the case) go to GND. Each resistor is 330 ohms and can face either way.

5. Connect the piezo and check the circuit

Connect the passive piezo signal lead to D9 and its other lead to GND. All GND connections share Uno ground. Check that no 5V wire touches GND before plugging in USB. Test using a broad flat object at 25, 13, and 8 cm.

  • This design uses a small passive piezo, not a high-current siren or magnetic buzzer.
  • The sensor works over approximately 2-400 cm. Missing or invalid echoes turn all lights and the buzzer off; this is not a safety-rated alarm.

Review all connections

1. Connections between "sonar" and "Arduino"

FunctionsonarArduino
powerVCC5V
groundGNDGND
digitalTRIGGPIO 7
digitalECHOGPIO 8

2. Connections between "lcd" and "Arduino"

FunctionlcdArduino
powerVCC5V
groundGNDGND
i2cSDAGPIO 18
i2cSCLGPIO 19

3. Connections between "buzzer" and "Arduino"

FunctionbuzzerArduino
pwmSIGGPIO 9
groundGNDGND

4. Connections between "r_red" and "Arduino"

Functionr_redArduino
digitalP1GPIO 2
digitalP2 → LED ANODEEXT

5. Connections between "red" and "Arduino"

FunctionredArduino
groundGNDGND

6. Connections between "r_yellow" and "Arduino"

Functionr_yellowArduino
digitalP1GPIO 3
digitalP2 → LED ANODEEXT

7. Connections between "yellow" and "Arduino"

FunctionyellowArduino
groundGNDGND

8. Connections between "r_blue" and "Arduino"

Functionr_blueArduino
digitalP1GPIO 4
digitalP2 → LED ANODEEXT

9. Connections between "blue" and "Arduino"

FunctionblueArduino
groundGNDGND

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

const uint8_t RED = 2, YELLOW = 3, BLUE = 4;
const uint8_t TRIG = 7, ECHO = 8, BUZZER = 9;
hd44780_I2Cexp lcd;
bool lcdReady = false;
char previous[4][21] = {};
int previousState = -1;


void row(uint8_t index, const char *text) {
  char padded[21];
  memset(padded, ' ', 20);
  padded[20] = '\0';
  size_t length = strlen(text);
  if (length > 20) length = 20;
  memcpy(padded, text, length);
  if (strcmp(previous[index], padded) != 0) {
    if (lcdReady) {
      lcd.setCursor(0, index);
      lcd.print(padded);
    }
    strcpy(previous[index], padded);
  }
}

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);
  Wire.begin();
  lcdReady = (lcd.begin(20, 4) == 0);
  if (!lcdReady) Serial.println(F("LCD not detected: check wiring and contrast."));
  row(0, "Distance monitor");
}

void loop() {
  digitalWrite(TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);
  unsigned long duration = pulseIn(ECHO, HIGH, 30000UL);
  float cm = duration / 58.0f;
  bool valid = duration != 0 && cm >= 2.0f && cm <= 400.0f;
  
  int state = !valid ? 0 : (cm >= 20.0f ? 1 : (cm <= 10.0f ? 3 : 2));
  if (state != previousState) {
    digitalWrite(RED, state == 1);
    digitalWrite(YELLOW, state == 2);
    digitalWrite(BLUE, state == 3);
    if (state == 3) tone(BUZZER, 4000);
    else noTone(BUZZER);
    previousState = state;
  }
  char distanceText[21];
  if (valid) {
    char number[10];
    dtostrf(cm, 5, 1, number);
    snprintf(distanceText, sizeof(distanceText), "Distance: %s cm", number);
  } else strcpy(distanceText, "Distance: no echo");
  row(1, distanceText);
  if (state == 1) {
    row(2, "The Distance is far"); row(3, "");
  } else if (state == 2) {
    row(2, "Object is Closer"); row(3, "");
  } else if (state == 3) {
    row(2, "The OBJECT is"); row(3, "TOO CLOSE");
  } else {
    row(2, "No valid reading"); row(3, "Check target/sensor");
  }
  Serial.println(distanceText);
  delay(100); 
}

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