Ultrasonic Spider-Sense

About: My name is Jason Poel Smith I am a Community Manager here at Instructables. In my free time, I am an Inventor, Maker, Hacker, Tinker, and all around Mad Genius
More About DIY Hacks and How Tos »

We would all love to have superpowers. But you probably don't want to expose yourself to toxic chemicals or radiation in order to get them. Fortunately, there are some abilities that we can closely approximate with a little technology.

For example, Spider-Man has a "spider sense" that alerts him to nearby danger, and Daredevil's "radar sense" lets him see nearby objects even in the dark. Using an ultrasonic range sensor we can sense how far away objects are. This would let you navigate in the dark or detect when someone is sneaking up behind you.

Step 1: Watch the Video

Here is the video walkthrough of the project.

Step 2: Materials

Here are the materials and tools that you will need for this project.

Materials:

Arduino Microcontroller

Ultrasonic Range Sensor

Piezo Buzzer

LEDs (optional)

3V Pager Motor (optional)

Insulated Wire

An Old Jacket

Optional Driver circuit parts:

MOSFET Transistor (such as the IRF510 Power Transistor)

22 ohm Resistor.

1 kohm Resistor

0.1 microfarad capacitor

Printed Circuit Board or Perf Board

Tools:

Wire Strippers

Wire Cutters

Soldering Iron

Step 3: Decide on How You Want the System to Alert You

The first thing that you need to decide is how the system will alert you to the oncoming danger. There are a lot of options to choose from. Here are a few examples.

Sound: You can use a small piezo buzzer to let you know how far away something is. Using the PWM output of the Arduino, you can change the pitch of buzzer to indicate how far away something is. You can easily hide these buzzers somewhere in a coat. The disadvantage of a buzzer is that other people nearby may also hear the buzzer. So you may give away the fact that you know that they are coming.

LEDs: LEDs are probably the simplest kind of indicator that you can use. They are silent and discreet. They can be hidden in a number of places. For instance, you can hide LEDs under your sleeve. The fabric of a thin cotton shirt will let you see the LEDs when they are lit up but still cover them up when they are not turned on. The disadvantage of this system is that you need to be looking at them in order to notice the alert.

Vibration: You can have the output of the sensor activate a pager motor. The major advantages of this option are that it is almost silent and it doesn't require you to be looking in any particular direction. It is also the option that is most similar to Spiderman's spider-sense which is described as "tingling" feeling at the base of his skull.

You can also combine multiple kinds of alerts. For instance, you can have a buzzer alert you when someone first comes in range of the sensor. This could prompt you to look at an LED display to see exactly how far away they are.

Step 4: Optional Output Driver Circuit

The digital pins on an Aduino can only output a maximum of 40 mA (It is recommended that you stay below 20 mA). Many output devices will require more than this to operate. For example a pager motor can require between 50 mA and 200 mA. If you want to use higher powered output devices, you need to build some kind of external driver circuit.

Here is a simple example of a driver circuit. The power for this circuit can be supplied by the 5V pin. The 5V pin is directly connected to the voltage regulator that powers the board. So it can output a much higher current than the digital pins. Check the specifications of your board for an exact number.

First prototype everything on a breadboard. Then I soldered it onto perf board.

Step 5: Connect the Ultrasonic Range Sensor to the Arduino

The ultrasonic sensor has four pins on it (GND, Vcc, NC, and SIG). GND connects to the GND pin on the Arduino. Vcc connects to the 5V pin on the Arduino. NC has no connection. SIG connects to a digital output pin on the Arudino. This ultrasonic sensor came with a short female to female connector cable. I added a second set of wires so that I mount the sensor further away from the Arudino board. To connect two female ends together, I used four short pieces of wire that were clipped from resistor leads.

If you are using an external driver circuit like the one described in the previous step. You will need to have two wires connected to the 5V pin on the Aduino board. In this case, you may consider connecting the driver circuit to the 5V pin on the Arduino and connect the Vcc wire on the sensor to the corresponding connection on the driver's circuit board.

Step 6: Sample Arduino Code

pinMode(3, OUTPUT); // sets the digital pin 3 as output for a buzzer pinMode(4, OUTPUT); // sets the digital pin 4 as output for an LED pinMode(5, OUTPUT); // sets the digital pin 5 as output for an LED pinMode(6, OUTPUT); // sets the digital pin 6 as output for an LED pinMode(7, OUTPUT); // sets the digital pin 7 as output for an LED pinMode(8, OUTPUT); // sets the digital pin 8 as output for an LED pinMode(9, OUTPUT); // sets the digital pin 9 as output for an LED pinMode(10, OUTPUT); // sets the digital pin 10 as output for an LED pinMode(11, OUTPUT); // sets the digital pin 11 as output for an LED pinMode(12, OUTPUT); // sets the digital pin 12 as output for an LED pinMode(13, OUTPUT); // sets the digital pin 13 as output for an LED Serial.begin(9600);

long microsecondsToInches(long microseconds) { // According to Parallax's datasheet))), there are // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per // second). This gives the distance travelled by the ping, outbound // and return, so we divide by 2 to get the distance of the obstacle. return microseconds / 74 / 2; }

long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }

Attachments

Step 7: Mount the Arduino in an Insulated Project Housing

It is always best to have your Arduino board in some kind of a housing. This helps to protect the board and it helps to keep all the wires in place. To secure the board in place, you can tape one of more sides of the board to the wall the housing. Then cut holes in the side of the housing for any wires.

Step 8: Mount All of the Parts Onto an Old Jacket

Now you need to attach the sensors, the alarms and the arduino to an old jacket.

The Ultrasonic sensor can be attached to the side of a sleeve. This lets you easily move it around and point it in any direction that you want. The board for the sensor had three large mounting holes on it. These were convenient places to sew the board to the coat. Just loop thread through each hole and through the sleeve to secure it in place.

A buzzer can be attached to the inside collar of the jacket or in a hood. Just sew it to the fabric at the mounting holes.

An LED strip can be positioned inside a sleeve of the jacket or in the sleeve of a shirt.

The Arduino and its housing can usually fit into one of the front pockets. You may need to cut a hole in the inside of the pocket to the wires to from the Arduino to the inside of the coat.

Run all of the wires through the inside of the jacket. To prevent the wires from getting tangled, you may want to sew the wires to the inside of the jacket at several points.

You can now use your sensor to detect objects in the dark or sense when someone is sneaking up behind you. Just point the ultrasonic sensor in any direction and monitor your chosen alert system. Point the sensor behind you and you will know when people are approaching you even without seeing them. Point the sensor in front of you to detect objects in the dark. It is just like having super powers...sort of.

Sorry. But I don't sell any of my projects. I just write the how-to instructions for them. But if you really want to buy something similar, ThinkGeek sells one that senses when someone walks up behind you.