Introduction: Use a DIY Proximity Sensor to Automate Your Haunted House

Picture of Use a DIY Proximity Sensor to Automate Your Haunted House

The special effects in a haunted house need to be well timed. The best way to do this is to use sensors to detect where your guests are in the haunted house. So I am doing a series of projects that demonstrate a variety of sensors that you can use to automate your haunted house. Last week I showed how to make a simple DIY pressure plate switch.

This week, I am going to show you how to make a proximity sensor and how you can implement it to activate special effects. 

Step 1: Materials

Picture of Materials

Here are the materials and tools that you will need to make a simple proximity sensor:

Infrared LED
Infrared Phototransistor
33 ohm Resistor
10 kohm Resistor
Black Heat Shrink Tubing (the same diameter as the phototransistor)
Perf Board

Soldering Iron 

Step 2: How an Infrared Proximity Sensor Works

Picture of How an Infrared Proximity Sensor Works

To make a simple proximity sensor, all you need is a light emitter and a light detector. The light emitter is constantly on. Whenever that light hits a nearby object, some of the light is reflected back to the detector. The closer the object is, the more light will be reflected. By measuring the output of the light detector, you can get a rough approximation of how close the object it.

This isn't exact because the amount of reflected light also depends on the physical properties of the reflecting surface (sometimes called its reflectivity). However, it works well enough to use to activate special effects in a haunted house.

I chose to use infrared light for this sensor because it is invisible to the human eye. So your guests won't notice it. Also it won't experience as much interference from the lighting in the room.

Step 3: The Sensor

Picture of The Sensor

The IR LED is connected to the 5V supply with a 33 ohm series resistor. To find the appropriate resistor value for the LED use this formula:

Resistor Value = (Supply Voltage - LED Voltage) / LED Current.

In my circuit, the supply voltage is 5V. The LED is rated for 1.3V at 150 mA. This gave a resistor value of 24.7 ohm. The closest resistor that I had above this value was a 33 ohm resistor. So I used that. Be careful to not overload the resistor. A 33 ohm resistor will experience about 1/2 watt if power. If you don't have a resistor rated for that much. You can use two 68 ohm resistors in parallel. Or you can use multiple LEDs in series to bring down the voltage across the resistor.

The emitter of the phototransistor is connected to ground. The collector is wired to a 10 kohm resistor that is connected to 5V. An additional wire is connected to the collector to act as an output pin for the sensor. I soldered the sensor components together on a small piece of perf board. I added three pins to connect the sensor to the signal processor.

To ensure that only reflected light is detected by the phototransistor, it is important to add a light barrier between the LED and the phototransistor. The most effective way to do this is to put a black piece of heat shrink tubing around the phototransistor. This also helps to make the sensor more directional.

Step 4: Signal Processing With an Arduino

Picture of Signal Processing With an Arduino

In most cases you will use a microcontroller such as an Arduino to monitor the signal from the sensor. To do this, connect the ground terminal from the sensor to the GND pin on the Arduino. Connect the 5V wire from the sensor to either the 5V pin or a digital output pin set to HIGH. Then connect the signal wire from the sensor to an analog input pin on the Arduino. 

The AnalogRead function measures the voltage of the signal coming from the sensor. When the voltage drops below a set threshold, the Arduino activates the your special effects. Here is an quick example of the code that you could use. 

// Example Code
int InputPin = 0;      // analog pin 0 is the input pin
int OutputPin = 1;   // digital pin 1 is the output pin
int val = 0;              // variable to store the value read

void setup()
pinMode(OutputPin, OUTPUT);      // sets the digital pin as output

void loop()
  digitalWrite(OutputPin, LOW);    // sets the output pin initially to LOW
  val = analogRead(InputPin);        // read the input pin 0 to 1023
  if (val < 800)                              // if sensor value is below threshold set output HIGH
  digitalWrite(OutputPin, HIGH);    // sets output pin HIGH to activate special effects
delay(1000);                  // waits for a second

Step 5: Signal Processing With an OP Amp

Picture of Signal Processing With an OP Amp

If you don't have an Arduino, you can use an op-amp (operational amplifier) to monitor the signal from the proximity sensor. All you need is a 741 op-amp IC and a potentiometer (variable resistor). Connect the 5V supply to one side of the potentiometer and to V+ pin on the IC. Connect the ground wire to the other side of the potentiometer and to the V- pin on the IC. Then connect the non-inverting input (marked as "+" to the center lead of the potentiometer. Lastly connect the inverting input (marked as "-") to the signal wire from the sensor. 

This configuration of the op-amp functions as an adjustable comparator. The potentiometer sets the reference voltage for the sensor. Then whenever the signal from the sensor drops below this reference voltage the output goes HIGH.

Depending on what kind of circuit you want to activate, you may want the output to be a LOW signal instead. You can do this by switching the wires connected to the op-amp's input pins. So if you connect the sensor to the non-inverting input and connect the potentiometer to the inverting input, the output will be LOW whenever the sensor is activated. 

Step 6: Use Your Proximity Sensor to Activate Your Special Effects

Picture of Use Your Proximity Sensor to Activate Your Special Effects

You can use the output of this device to activate just about any kind of special effect. You can use the proximity sensor to activate a prop on a servo like my motion tracking skull project. You can use it to activate sound effects like a scream. But my favorite application is the automatic coffin. The coffin is closed as you approach it. But as soon as you get close to it, the door swings open with a zombie inside.

To see a really good tutorial on how to make an automatic coffin, check out this instructable by instructable user wannabemadsci.


KonstantinosC7 (author)2017-03-09

hi there.... fantastic idea of the motion detector can i make it work as a microphone switch. when the person who wants to talk just approaches the mic and it will open ,and when he/she sits back for it to close??? any ideas??? please help...

RobertC2 (author)KonstantinosC72017-08-25

You will need to mount the sensor on the mic stand under the mic, aiming toward the person talking, and use a 5V relay to interrupt the mic's wiring. You will need to cut an extra mic cable to do this, preferably a short one. If your mic uses XLR (3 pin) connectors, look up how they work to be sure you wire it right.

I am not really sure how you would set that up

chago1 (author)2016-12-28

Does this work in most lighting conditions? thanks

No. It works best in low light. Bright lights (especially daylight) can mess with the sensor.

MhaleM1 (author)2016-07-26

Hello, my name is Mhale Metha, im from Nagaland, it is situated in the North East of India.
Your post helped me alot and thank you so much, i want to know something more,
I only have one arduino and my project is about 25 to 30 proximity sensors, please tell me how to connect all the sensors in one arduino, thank you.

Since you don't have that many inputs on the Arduino, you will need to combine a few of them. To do this use a diode to connect the sensor to the Input pin with the cathode connected to the sensor and the anode connected to the Arduino input pin. You can connect multiple sensors in parallel like this. When any one of them sends out a LOW signal, the Arduino will register as LOW. You may need to add a pull-up resistor between the input pin and 5V.

Sarvasv Kulpati (author)2016-05-02

If I had to use three of these sensors, how would you recommend connecting them to an arduino or a 6v battery pack(with appropriate resistors)? Should I connect each of them individually to the battery/ arduino or in series?

Make three identical sensors (IR LED, receiver, and resistors. Connect them all to different input pins on the Arduino. Connect the GND pins and 5V pins to each sensor in parallel. Then connect the batter yto the power input (Vin) Arduino.

Thanks for the reply! Would it be possible to run two servos as well as these sensors on the same battery?

That all depends on the current requirements of each component. High torque servos use a lot of current and using two at once might drain the battery pretty quick.

I'm so sorry I keep pestering you with questions, but I just want to be safe. Is this a schematic of what you are describing? (ignore the analog input, I couldnt find anything to replace the sensors other than an led)

p.s. im fourteen and this is the first time im trying to write a comprehensive instructable so thanks for any help

That looks about right. But you want to check the current rating of your servos and make sure that you aren't exceeding max current of the 5V pin.

sagarganji678 (author)2016-03-31

Can i use dc motor at output of ic741( when ic741 is used instead of arduino)

You could. But you want to make sure that the current required by the motor doesn't exceed the output current limit of your chip. You may need to use a transistor to control high current motors.

GouthamC (author)2016-03-16

can u say how d skull is moving ?

i mean have u kept any sensor inside in it ?

ad hw much of load is reqrid fr moving it

plzzzz reply me

The skull is moved with a single servo motor. To see an example of how I did this for a full project, check out this Instructable:

sshetty11 (author)2016-02-19

Hey..... I need to make a sensor for a range of about 3-6 feet or so.... Can u recommend the components... Would be a huge help.... Thanks ?

At that range, you want to use an ultrasonic range sensor. There are a lot of different models that can interface directly with an Arduino.;=1C1CHFX_enUS492US492&oq;=arduino+ultrasonic+range&aqs;=chrome.0.0j69i57j0l4.7560j0j7&sourceid;=chrome&es;_sm=122&ie;=UTF-8#q=arduino+ultrasonic+range+finder&tbm;=shop

schildress4 (author)2015-11-03

Would this sensor work on a device like this?

Maybe. I am not very familiar with that device. But it should work with anything that can do an analog read function.

ok I was wondering cause I want to made one for our robotics team

schildress4 (author)schildress42015-11-03

forgot some pics :P

ajdajd made it! (author)2015-10-21

Here's an early breadboard prototype of mine. Works like a charm indoors. Had about a maximum of 20 inches in detectable length. But the voltage response is really different outdoors. Probably it's the sun. :(

I was really hoping a "simple" sensor like this would work outdoors, without resorting to using modulation. Oh well.

Yeah. For outdoor used, you want to either use a 30kHz carrier wave like this:

Or you can use an ultrasonic range sensor like this:

Wow thanks for the links! Will definitely look at them.

Quick question: Would you know what material I can use to cover the infrared parts if I put it in an enclosure? Say I put it in a metal case, I'd make a window for the IR LED and photodiode but I want to cover it. I'm thinking of acrylic, but what factors should I consider? Thanks!

Any thing that lets light through can be used as a cover. If you are using the 30kHz carrier wave design, you can even use partially opaque materials.

PinakiG (author)2015-08-16

Yes, then it is surely a photo diode not a photo-transistor, plus the 33R should be of 2 Watt since the IR LED consumes 100mA not 20 mA with a forward voltage drop of 1.06v. The 10K should also be replaced with a 50M to do anything practically (car parking sensor) i guess. I free to an open minded discussion. LM358 can also be used. But the overall sensitivity I need 2-3 feet. This type of circuits are not as sensitive even compared to a TV remote control like things. I just tested it on my breadboard. What is your opinion?

The sensitivity also depends on the amount of ambient light in the area. If there is a lot of light hitting the photodiode, you might want to add a IR light filter.

PinakiG (author)2015-08-14

From your finished circuit it appears to be that you used a photo diode, but all your diagram is showing a photo-transistor. Photo-diodes and Photo-transistors are quite different in nature. What should I use, a photo-diode or else? What is the actual component you used? Please resopnd early as I am going to build you circuit and I am confused with that component. Please help.

These are the exact components that I used.

dinesh karthik (author)2015-04-18

hai... can the sensor work with 330 ohm resistors............

Yes, but it won't be as sensitive.

vgregorio (author)2015-04-10

Would there be any modification on the circuit if my phototransistor has a base? Beause the phototransistor I bought have 3 pins. Thanks :)

In most cases you can just ignore the base pin and leave it unconnected. It is just there in case you wanted to be able to activate the transistor with other components when the LED is not on.

ronit1 (author)2015-03-25


aki95 (author)2015-02-03

Can you give more information about the potentiometer

The potentiometer in step 5 is just a regular 10 kohm potentiometer. It measures 10 kohms across the two side terminals and the resistance to the middle terminal changes based on how you have the knob turned. On end is connected to the ground. The other end is connected to 5V. The center terminal is connected to the OP AMP.

Michalsky (author)2014-12-17


muss the wavelength of the IR Phototransistor and IR LED match by 100% or is it enough to consider only the range of both?

I have been using following:


but it is not working properly I have changed the 33 Ohm resistor too, but the LED is either on or off and sometimes it looks like having interference Im not sure whats going wrong.


Most IR LEDs and phototransistors should work. Check the polarity and look for shorts.

Louis-AeronT (author)2014-12-06

Typo! Is there any set petentiometer we should use? Thanks!

No. You will probably need use some trial and error

Louis-AeronT (author)2014-12-06

Hi. Cool circuit; I am trying to make with the op amp, but having trouble getting it to work. For the potentiometer, is there are set ratings?

fadecomic (author)2014-10-26

I built this circuit, but my 33 ohm resistor is getting extremely hot. (5-1.3V)/33 = 112 mA, and P = I^2 R = 0.414 W, which is much more than the 0.25 W an off-the-shelf resistor is rated for. Did you experience the same?

That is a good point and I need to make that more clear in the instructions. Here are some solutions.

1. Use a larger resistor value and bring down the current to below 0.25 W.

2. Use multiple IR LEDs. Using three LEDs in series will have a combined voltage of 3.9V. So the voltage across the resistor would only be 1.1V. At 150mA that is only 0.165W on the resistor.

3. Use two 68 ohm resistors in parallel. This effectively gives double the wattage capacity.

rpd16349 (author)2014-10-04

what is the maximum distance that can be detected by the sensor..

thank you

That depends mostly on how much interference there is from the surroundings. It will work best in the dark. But a few feet is the best that you could ever expect.

TheNotoriousHoppington (author)2014-08-08

Is it possible to make a more advanced version of this? Instead of a light, it sends a message to another device wirelessly?

It is absolutely possible but that setup would be a lot more complicated.

hrayhan (author)2014-07-05

can i use regular phototransistor?

About This Instructable




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: