Introduction: Ultrasonic Spider-Sense

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

AidanC7 (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.

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.

Could you possibly link that think geek page?

LukeS169 (author)SpodermenSweg2017-03-26

Bro just google it

Could you possibly link that think geek page?

Could you possibly link that think geek page?

Thanks for letting me know

Ethan1023 (author)2016-05-12

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

akshay.d21 (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 :))

nahiyan.ahmed.142 (author)2015-02-28

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

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

nahiyan.ahmed.142 (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..................

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

VikramD (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? )

No the ultra sonic ping will not go through fabric.

Justbender (author)2014-12-19

Hey thanks for this project!

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

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

Ty'RaeJ (author)2014-11-17

can you make a code for vibration

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

NickF3 (author)2014-11-13

o rite cheers mate and I will do !!

NickF3 (author)2014-11-13

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

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.

Ty'RaeJ (author)2014-11-11

Which arudino kit can someone tell me.

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

thxs

walshlg (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.

eruger (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.

That is definitely possible.

Sooo much to learn :D

leven (author)eruger2014-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.

DIY Hacks and How Tos (author)2014-10-13

The range of the sensor is 3-4 meters. The pulses fan out in a cone and it registers the nearest object that is big enough to reflect the pulse at that distance. The farther away an object is the larger it needs to be to be detected. So a piece of furniture at 4 meters or baseball at 1 meter.

billbillt (author)2014-10-12

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

eruger (author)billbillt2014-10-12

I agree!

Mercurion925 (author)2014-10-10

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

seamster (author)2014-10-09

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

About This Instructable

36,355views

473favorites

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:36 Things to Cook in a Coffee MakerHow to Make a Festivus PoleAdd Wings to an Infant's Halloween Costume
Add instructable to: