Supplier photo of an assembled infinity mirror light cube illuminated on a dark background.
Supplier photo
Temu affiliate offer · Project idea

Build an infinity light cube

Listing specifies 5-volt direct current. Soldering required; battery and glue not included.

View kit on Temu

Tricky Circuit may earn a commission through these links. Product ideas have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

📡 What is the HC-SR04?

The HC-SR04 is an ultrasonic distance sensor that measures the distance to objects using high-frequency sound waves (ultrasound). Think of it as a bat-like echo radar! 🦇


🧠 How It Works

  1. The TRIG pin sends a short pulse (10 microseconds).
  2. The module emits an ultrasonic burst at 40 kHz.
  3. If the sound wave hits an object, it reflects back.
  4. The ECHO pin goes HIGH for the duration it took the wave to bounce back.
  5. Arduino measures that time and calculates the distance.

📐 Distance Formula

distance_cm = (duration * 0.0343) / 2;
  • Speed of sound: ~343 m/s = 0.0343 cm/µs
  • Divide by 2 because the sound travels to the object and back

🔌 Pinout

PinFunction
VCCPower (5V)
GNDGround
TRIGTrigger signal input
ECHOEcho signal output

⚙️ Arduino Code Example

const int trigPin = 9;
const int echoPin = 10;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  // Clear the trigger
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  // Send a 10 µs pulse
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the echo time
  long duration = pulseIn(echoPin, HIGH);

  // Calculate the distance
  float distance = duration * 0.0343 / 2;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  delay(500);
}

✅ Pros

  • Super cheap 💰
  • Easy to use
  • Accurate enough for most robotics
  • Works on 5V — no logic level conversion needed

⚠️ Limitations

  • Doesn’t work well with soft or absorbent surfaces (like cloth)
  • Can’t detect transparent objects (like glass)
  • Has a minimum range of ~2 cm
  • Noisy environments can cause false readings

🤖 Use Cases

  • Obstacle-avoiding robots 🚗📡
  • Auto water level sensors
  • DIY radar systems
  • Motion detection

Wanna go further? I can show you:

  • A real robot project using HC-SR04
  • 3D-printed mount for it
  • Comparison vs VL53L0X laser sensor
    Just say the word! 🚀📏
📡Broadcast the signal — amplify the connection.

Leave a Reply

Temu affiliate offers

Find your next electronics project

Explore these do-it-yourself project kits. Check the selected option, included parts and instructions on each offer.

Tricky Circuit may earn a commission if you buy through these Temu affiliate links. These are product ideas; they have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

Supplier photo of a breadboard, jumper wires and assorted electronic components in a plastic storage case.

Supplier product photo

Try breadboard experiments

Breadboard, wires and assorted parts. Arduino controller board not included.

View kit on Temu

Supplier photo of an assembled blue surface-mount soldering practice board with a circular ring of small lights.

Supplier product photo

Solder a chasing-light board

Surface-mount soldering practice. Battery and battery holder not included.

View kit on Temu

Supplier photo of an assembled two-wheeled line-following car with a blue circuit board, two motors and an empty battery holder.

Supplier product photo

Build a line-following car

Soldering and assembly required. Check battery and track requirements before buying.

View kit on Temu