All packs

Sensors

Distance alarm

A sensor that beeps when something comes closer than 20 cm. The same idea as a car's parking sensor.

  • Medium
  • about 30 min
  • Arduino Uno
  • No soldering
  • 6 parts
  • 6 wires
  • 28 lines of code
Try it in the simulator

Opens this circuit, already wired, with the sketch loaded. Free, nothing to install.

Idea

Put it on a desk, a shelf or a bedroom door. The sensor sends out a sound too high to hear and times the echo, so it measures distance without touching anything.

What you learn

Timing an echo with pulseIn(), turning a time into centimetres, and making a decision with if.

How it works

  1. input

    HC-SR04 distance sensor

  2. decides

    Arduino Uno

  3. output

    Buzzer

Powered with 5 V from the Uno's USB cable. No battery and no soldering.

This circuit and sketch are run in the ManuStem simulator before the pack is published. Real parts vary between makers: follow the labels printed on your own module, not its position in the picture.