Use a DIY Proximity Sensor to Automate Your Haunted House
Intro: 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
Materials
Infrared LED
Infrared Phototransistor
33 ohm Resistor
10 kohm Resistor
Black Heat Shrink Tubing (the same diameter as the phototransistor)
Perf Board
Tools:
Soldering Iron
STEP 2: How an Infrared Proximity Sensor Works
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
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
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
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
To see a really good tutorial on how to make an automatic coffin, check out this instructable by instructable user wannabemadsci.
https://www.instructables.com/id/Halloween-Remote-Controlled-Casket/
82 Comments
leethayer8 9 months ago
electronerd224 3 years ago
This is a great DIY. Thanks for sharing valuable information. How much was the overall cost for this? I'm sure it was not too expensive. Also in this article https://www.derf.com/an-overview-on-proximity-sensors/ I was trying to understand the whole concept of proximity sensors but want to know more about Ultrasonic proximity sensors. Any use case would be very helpful.
gdgregdenton 3 years ago
chago1 7 years ago
DIY Hacks and How Tos 7 years ago
No. It works best in low light. Bright lights (especially daylight) can mess with the sensor.
VatslavO 6 years ago
DIY Hacks and How Tos 6 years ago
KonstantinosC7 7 years ago
hi there.... fantastic idea of the motion detector ....how 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 6 years ago
DIY Hacks and How Tos 7 years ago
I am not really sure how you would set that up
MhaleM1 7 years ago
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.
DIY Hacks and How Tos 7 years ago
Sarvasv Kulpati 7 years ago
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?
DIY Hacks and How Tos 7 years ago
Sarvasv Kulpati 7 years ago
Thanks for the reply! Would it be possible to run two servos as well as these sensors on the same battery?
DIY Hacks and How Tos 7 years ago
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.
Sarvasv Kulpati 7 years ago
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
DIY Hacks and How Tos 7 years ago
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 8 years ago
DIY Hacks and How Tos 8 years ago
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.