Ultrasonic Spider-Sense




About: My name is Jason Poel Smith. In my free time, I am an Inventor, Maker, Hacker, Tinker, and all around Mad Genius

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.


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


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.

Superheroes and Supervillains Contest

Runner Up in the
Superheroes and Supervillains Contest

Tech Contest

Participated in the
Tech Contest

Microcontroller Contest

Participated in the
Microcontroller Contest



    • Classroom Science Contest

      Classroom Science Contest
    • Sensors Contest

      Sensors Contest
    • Barbecue Challenge

      Barbecue Challenge

    36 Discussions


    10 months ago on Introduction

    Sounds like fun but may confuse the hell out of the local bats!


    3 years ago

    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.

    6 replies
    DIY Hacks and How TosAidanC7

    Reply 3 years ago

    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.


    3 years ago

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


    3 years ago on Introduction

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

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

    1 reply

    4 years ago on Introduction

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

    1 reply

    4 years ago

    Hey thanks for this project!

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

    1 reply