Introduction: Vibrating Distance Sensor

About: I specialize in electronics, but I can operate a band saw, ride a skateboard, and brew a tasty cuppa. I blog incessantly.

Imagine waking up next to a light sleeper and you have to get to the bathroom but you're in an pitch black hotel room. Even a flashlight will wake him or her up but you can't hold it for the next three hours when the alarm goes off. What if you could navigate a hotel room like a bat navigates a cave?

With a vibrating distance sensor you can "feel" walls up to fifteen feet away rather than groping blindly.

The vibrating distance sensor gives you sonar vision with no training. The flashlight enclosure is easy to build and intuitive to use. Feedback is a vibrating motor that vibrates strongly when an object is close then vibrates weakly when an object is far away. Kids have picked this up and automatically began testing the range of walls and ceilings with no one telling them how to operate it. Just point it where you want to look/feel and you sense if there is something in the way.

This project involves soldering, cutting, drilling, sanding, measuring, and downloading a program to an Arduino.

Step 1: Shopping List

Flashlight.* Rayovac Economy 2D 9 Lumen model. Get the red model with the black bezel. Amazon link.
Ultrasonic distance sensor
9V Connector
9V battery
Attiny85 Arduino
Tactile switch
Vibrator motor
STL Model for flashlight adapter

3/4" #10 bolt*
#10 end nut *
Super glue
Hot glue stick
1" Schedule PVC * White plumbing pipe
* These items are cheaper to purchase from a hardware store than order online.

While we're gathering everything I want share the files for this project. The necessary one is the Arduino code.

There is an .stl file but if you don't have a 3D printer you can move to the next step after downloading the Arduino code. If you can print that you won't have to cut the adapter in the next step.

For the hackers who want to see all the inner workings of the 3D models I have the OpenSCAD files on my blog. They're freely available so if you want to use a different flashlight you can easily tweak things and make a model to fit lots of different flashlights. There are also .dwg files for people with laser cutters or CNC machines.

Downloadable files for Vibrating Distance Sensor:

Step 2: Flashlight Adapter

By the end of this step we will end up with an adapter to hold a distance sensor in a flashlight. This part is visible so I recommend doing a neat job. The yellow and green image is animated so expand it to get a good idea of what we're making.

If you printed the .stl file from the previous step you can skip this step now.

This part is small so it is easy to print off a template on a standard paper printer. Download the .pdf and print it at 100% scaling. Don't worry if some of the borders are cut off. When printed at 100% the scale at the bottom will align with a ruler exactly. Cut out the templates from wood or plastic. Your material should be at least 2mm thick but less than 13mm thick. Hole sizes and positions are printed right on the file.

When the part it done it should fit easily into the black flashlight bezel and not stick in place. It is fine if the piece rattles a little bit, don't worry, it won't rattle once it's assembled.

Step 3: Electrical

This is the step with soldering.

I've included a schematic image above. On my blog I even provide a .dwg of the schematic if that's your thing. If not, that's cool too. The rest of the pictures go in order of what to do if you would rather have a step-by-step pictorial of the soldering steps.

Soldering the thin wires of the vibrator can be tricky so once you get it I recommend gluing the vibrator to the Arduino. Hot glue works well but so does double sided foam tape.

Once everything is soldered, adhere the distance sensor to the adapter made in the previous step. Hot glue and double-sided tape work well for this too. It is not necessary to use special glue since the distance sensor will be held in place once the flashlight bezel is tightened onto it.

If you apply power to the Arduino now the vibrator motor should pulse in time with the LED. This is a good way to test the power and vibrator circuit.

Step 4: Program the Arduino

If you haven't already downloaded the project's Arduino code please do so now.

If you have used a DigiSpark then you know the ropes. If not please follow the steps shown by DigiStump, the people who make the DigiSpark.

The difference will be adding an Additional Board Manager URL at:

Step 5: PVC Cutting and Drilling

I wrestled with different method of using the switch built into the flashlight. I even considered ripping it out and putting in a brand new switch but the elegance of using the original switch was too much. With that said, some of you hackers will have no problem changing this step around to suit yourself. Some ideas would be to use a LiPo battery pack instead of the 9V battery or a high capacity 12V battery. A lighted switch would look pretty cool, just saying.

1" PVC, the cheap plumbing kind, is roughly the same diameter as a D-cell. This works well to fill the space where the bulky batteries would normally go.

  1. Cut a 5 3/4" (145mm) length of the pipe.
  2. Cut out a space for the 9V battery. This could be cut with a saw or router. It should be secure but easy to remove
  3. Place the pipe inside the flashlight and push it to the bottom of the handle
  4. Align the pipe so there is plenty of pipe right under the switch.
  5. Drill a 3/16" (4mm) hole though the flashlight and pipe
  6. Put a #10 (4mm) bolt through this hole.

This pipe serves two purposes. The first reason is to hold a small, inexpensive tactile switch under the flashlight's switch. Secondly the pipe will hold the 9V from rattling around and tugging on wires. You want it to feel sturdy, don't you?

Step 6: Last Step and It Is Easy

We want to position that little black button under the flashlight's switch so when it is pushed forward the button is held down. The button will be glued in place and that's about it.

To align the switch:

  1. Install the PVC pipe and position it with a bolt. There is not need for a nut yet.
  2. Make sure the flashlight switch is in the OFF position.
  3. Use tweezers or thin pliers to position the button where it will be pressed when the flashlight switch is fully forward.
  4. Use a hot glue gun to temporarily hold the switch in position.
  5. Switch the flashlight off.
  6. Remove bolt
  7. Remove PVC from flashlight handle.
  8. Use a marker or pencil to outline the switch position.
  9. Break the hot glue away from the PVC and switch.
  10. Use plastic glue or super glue to hold the switch in place.

Once the glue has dried reinstall the PVC and bolt like you did in the previous step. Switch the flashlight on so the button is pressed. There should be a small click. Add the nut while the button is held and do not over tighten the nut.

If everything has been done correctly you can start using your handheld sonar unit!

Step 7:

I hope you enjoyed reading or building this project.

This device was developed over the course of months and I documented every step. Some of those steps were fruitless and some were amazing breakthroughs. If you enjoy getting into the mind of someone who creates things like this please visit me.

I run a blog where I talk incessantly about the things I build, including an unabridged versionof this project. There are also other neat projects like a device which converts temperature to sound. You can also see how this project started as a servo feedback device which became a different Instructable first.