Introduction: Battery-Powered Ultrasonic Distance Detector for Moving in the Darkness

About: My life revolves around robotics.

Have you ever wanted to use the bathroom, or get a midnight snack without turning on the blindingly bright light? You have come to the right place, because in this Instructable, you will learn how to create an ultrasonic distance detector that helps navigate around your house in the dark, safely.

By using an ultrasonic sensor, distance can be calculated by the Arduino. This signal is then sent to the piezo buzzer, which buzzes at a rhythm, the intervals between each beep becoming shorter and shorter as the ultrasonic sensor approaches an object or wall. This Instructable was actually inspired by the use of echolocation in the natural world, like that seen in bats.

Because this is powered by a 9V battery, you can take it practically anywhere.

Supplies

You will need:

  • 1x Arduino Uno
  • 1x large breadboard
  • 1x mini breadboard
  • 1x 9v battery
  • 1x snap-on connector clip
  • 1x HC-SR04
  • 1x piezo buzzer
  • 8x jumper wires
  • 3x male to female jumper wires

You may also want:

  • Cardstock
  • Spraypaint

Step 1: Set Up Breadboard With Electronic Components

For this step, make sure to use elastic bands to secure your Arduino UNO and the mini breadboard to their places so they don't slide around later on.

The resistor is there to decrease the volume of the piezo buzzer. You can test out different ohms; I suggest trying a 220 ohm resistor, which produces an audible, but not too loud song.

Step 2: Wire Electronic Components to Their Respective Pins

PIN LAYOUT:

1. Ultrasonic sensor:

Vcc -> 5V

GND -> GND

Echo -> 11

Trig -> 10

2. Piezo buzzer

+ -> 5V

- -> GND

3. KY-008 Laser Module

+ -> 5V

- -> GND

Signal -> 4

Make sure to add 5V and GND "power lines".

Step 3: Write the Code

Easy, just use download the attached code!

By using map(), the signals from the ultrasonic sensor become the length of each interval between each beep of the piezo pin. Feel free to adjust the code to your own personal preference (for instance, adjusting the tone of the buzz).

Step 4: Create the Outer Casing (for Aesthetic and Protective Purposes)

Want to give your distance detector a protective case? Here, I have used the cardstock from a toothbrush product as the "barrel" that would go around your circuit board. Additionally, you can also color it, doodle on it, or even cut open parts to reveal the electronic insides. Let your creativity roam free!

Step 5: And... You Are Done!

That's it! Now, you can finally move around the house without turning on the lights. Just to be safe, make sure to move slowly (after all, you still are in the dark). See where your mind takes you; maybe you can add more on top of this projects. You still have many pins to connect to on the Arduino board.

Best of luck,

Aaron

Battery Powered Contest

Participated in the
Battery Powered Contest