Introduction: Ultrasonic Spider-Sense

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

const int pingPin = 2;

int sensingRangeUnit = 11; int buzzerLimit = 100; int buzzerFrequency;

void setup() {

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);

}

void loop() { long duration, inches, cm;

pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH);

// convert the time into a distance inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println();

if (inches < (sensingRangeUnit*1)) { digitalWrite(4, HIGH); } else { digitalWrite(4, LOW); }

if (inches < (sensingRangeUnit*2)) { digitalWrite(5, HIGH); } else { digitalWrite(5, LOW); }

if (inches < (sensingRangeUnit*3)) { digitalWrite(6, HIGH); } else { digitalWrite(6, LOW); }

if (inches < (sensingRangeUnit*4)) { digitalWrite(7, HIGH); } else { digitalWrite(7, LOW); }

if (inches < (sensingRangeUnit*5)) { digitalWrite(8, HIGH); } else { digitalWrite(8, LOW); }

if (inches < (sensingRangeUnit*6)) { digitalWrite(9, HIGH); } else { digitalWrite(9, LOW); }

if (inches < (sensingRangeUnit*7)) { digitalWrite(10, HIGH); } else { digitalWrite(10, LOW); }

if (inches < (sensingRangeUnit*8)) { digitalWrite(11, HIGH); } else { digitalWrite(11, LOW); }

if (inches < (sensingRangeUnit*9)) { digitalWrite(12, HIGH); } else { digitalWrite(12, LOW); }

if (inches < (sensingRangeUnit*10)) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); }

if (inches < buzzerLimit) { buzzerFrequency = (((buzzerLimit - inches)*255)/buzzerLimit); analogWrite(3, buzzerFrequency); } else { analogWrite(3, 0); } delay(100); }

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; }

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.

Step 9: Use Your Ultrasonic Sensor to Detect Hidden Objects and Oncoming Danger

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.

Comments

author
AidanC7 made it! (author)2015-09-13

hi, I think this is very cool and I am a very lazy American and I would like to know if you sell a set that is a led vibration combo. please let me know, thank you.

author

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.

author
SpodermenSweg made it! (author)SpodermenSweg2016-01-18

Could you possibly link that think geek page?

author
LukeS169 made it! (author)LukeS1692017-03-26

Bro just google it

author
SpodermenSweg made it! (author)SpodermenSweg2016-01-18

Could you possibly link that think geek page?

author
SpodermenSweg made it! (author)SpodermenSweg2016-01-18

Could you possibly link that think geek page?

author
AidanC7 made it! (author)AidanC72015-09-14

Thanks for letting me know

author
Ethan1023 made it! (author)2016-05-12

Spider-man, or DD, whichever you want. This is EPIC!

author
akshay.d21 made it! (author)2015-08-17

Hi, I loved the instructable ! Thanks for uploading.

i wanted to know whether a buzzer can be used with increasing frequency of beeps as distance decreases ? thanks :))

author
nahiyan.ahmed.142 made it! (author)2015-02-28

And yes. Please give a pic of the arduino sample code only for the sensor and buzzer.....

author

The example code can be copied from the text or downloaded from the attached file.

author
nahiyan.ahmed.142 made it! (author)2015-02-28

There is no manual how to connect the points in the arduino uno of an HC-SR04 ultrasonic sensor that has echo and tring....Please leave it in the comments..................

author

Here is a link to the manual
https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE/edit

author
VikramD made it! (author)2015-02-22

Hey, can the range pass through fabric ? (meaning if you put the range sensor on your hood, will it still detect objects forwards? )

author

No the ultra sonic ping will not go through fabric.

author
Justbender made it! (author)2014-12-19

Hey thanks for this project!

Where did you buy the tan "insulated case" you show with Arduino and 9v in

author

I bought it at RadioShack about 10 years ago. So it probably isn't available any more. But any housing can work.

author
Ty'RaeJ made it! (author)2014-11-17

can you make a code for vibration

author

The code should be the same. Just connect a transistor to the output pin and connect the pager motor to the transistor,

author
NickF3 made it! (author)2014-11-13

o rite cheers mate and I will do !!

author
NickF3 made it! (author)2014-11-13

how do you attach the ultrasonic range sensor if it has four pins with trig and Echo instead of sig ?

author

Look up the manual on that part. It should have instructions on how to hook it up. You can also try looking up tutorials for that part.

author
Ty'RaeJ made it! (author)2014-11-11

Which arudino kit can someone tell me.

author

I am using the Arduino Uno, but any of them should work.

author
Ty'RaeJ made it! (author)Ty'RaeJ2014-11-13

thxs

author
walshlg made it! (author)2014-10-13

Very FUN.

Try this folks its easy too!

BTW the 3 pin varieties work the same way. My personal experience is maxes out at 3.1 meters also sometimes doesn't see an oblique object such as a wall angled at a glancing angle.

author
eruger made it! (author)2014-10-12

Could you use a stepper or linear motor to produce a gradient of tactile pressure relative to the proximity without using a constant draw on that motor? (Meaning that power is only used to position the motor, not to hold it in position). I'm pretty much a nuts, bolts, hammer and glue guy, but I was just wondering.

author

That is definitely possible.

author
eruger made it! (author)eruger2014-10-13

Sooo much to learn :D

author
leven made it! (author)leven2014-10-13

Sure, if you use one with high(low? =) ) enough gear ratio, or a worm gear, there is no problem turning off the supply to the motor, best done by using the enable pin of the stepper driver.

author
billbillt made it! (author)2014-10-12

Wonderful build.... Double plus good.... Got my vote!.....

author
eruger made it! (author)eruger2014-10-12

I agree!

author
Mercurion925 made it! (author)2014-10-10

Awesome instructable! Maybe someone can miniaturize the design with an Arduino Nano or LilyPad as well. Nice work!

author
seamster made it! (author)2014-10-09

I love it. So nerdy, on multiple levels. Excellent work!

About This Instructable

35,827views

471favorites

License:

Bio: 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 ... More »
More by DIY Hacks and How Tos:How to Make a Festivus PoleAdd Wings to an Infant's Halloween CostumeBubble Bath That Never Runs Out Of Bubbles
Add instructable to: