Introduction: Hack Your Halloween With Phidgets
This project will show you how you can "hack" your Halloween decorations and get them to behave exactly how you want!
The Halloween decoration we are working with has the following default functionality:
- Activated by throwing switch (shown in video)
- Activated by a loud sound
Our goal for this project is to make it motion activated instead!
Step 1: Skills Required
For this project, you will need the following tools:
- soldering iron
- wire strippers
It will also help if you have some basic programming knowledge. We wrote the program that controls the decoration in C.
Step 2: Figure Out If Your Halloween Decoration Is "Hackable"
The first step is figuring out if you can modify your Halloween decoration. Usually, decorations will have a demo mode that will activate the electronic component of the decoration with a simple button or switch. If this is the case, you are in luck. You can simply replace the button with a relay in order to control the system.
Step 3: Components/Hardware List
Step 4: Project Overview
This project will have the following layout:
- PhidgetSBC4 will run our program code (written in C). It will be connected to the DST1200 sonar sensor and the REL2002 signal relay through the built in VINT Hub.
- The sonar sensor will be be used to detect objects.
- The relay will be connected to the demo wire of the decoration, and will be used to activate the decoration based on the readings from the sonar sensor.
Step 5: Cut Button Connection
In order to add our relay, we will need to remove the button. Simply cut the wires close to the button, and then strip off some of the insulation.
Step 6: Add Relay
Take the wires from the button and connect them to the relay.
Connect one wire to the Common terminal and one to the Normally Open terminal.
Step 7: Mount the DST1200 Sonar Sensor
Where you place the sonar sensor will depend on your application. This project will be installed in a outdoor haunted house where visibility will be low, so having the sonar sensor sit directly on top won't be a problem. Alternatively, you could mount the sonar above a doorway, or pointing up from the ground if you wanted to hide it.
We used some glue to mount the sonar sensor. Double-sided tape would also work great!
Step 8: Decide If You Need an Enclosure
This project will be outside, so having the electronics protected is essential.
The SBC will sit inside a waterproof enclosure with the relay. We extended the relay connection to the decoration by soldering on some wire, and we used a 350cm long Phidget Cable to connect the SBC to the sonar sensor.
Step 9: Writing Code
All the code for this project is already written and is included in the file halloween.c, so if you want to implement it, all you will have to do is modify a few things (serial numbers, timing, etc.) and compile it.
For more information on how to compile C programs on the SBC, check out these links:
Here is a quick overview of the code:
- Create DistanceSensor and DigitalOutput objects.
- Address Phidgets. See this video for more information.
- Subscribe to attach & detach events for the sonar and relay.
- In sonar attach event, set the data interval to 100ms (the minimum data interval)
- Subscribe to distance change events for the sonar.
- In distance change events, see if the object is closer than 1 metre, if it is, set the objectDetected variable to 1.
- In while loop, check if object has been detected. If so, turn relay on and then off (this will activate the decoration). Wait for four seconds, and then deactivate the decoration.