This week’s flashback has actually been in two MAKE publications past: MAKE Volume 03 and Make: Halloween Special Edition. The author, Eric Wilhelm, is no stranger to DIY, as he runs Instructables. Eric’s favorite holiday is of course Halloween, and so is ours. We’ve got just over 3 weeks left for you to get all your haunted house components synced up and ready to scare. Eric’s article will no doubt come in handy. For more where this came from, you can still pick up Make: Halloween in the Maker Shed. And be sure to enter our Make: Halloween Contest 2009!
Haunted House Controller
Build a relay board that lets your computer synchronize lights, motors, and other devices to a scary soundtrack!
By Eric J. Wilhelm
For the last 12 years, I’ve been perfecting my technique of scaring kids. This project shows you how to build a tool I use in my haunted houses: a relay board that switches on electrical devices in time to an audio file that’s playing on a laptop, connected via parallel port. Using this setup, you can write code that synchronizes lights, motors, fog machines, pumps, laser pointers, and other devices to cues in a spooky soundtrack.
120V AC solid state relays logic-compatible input voltage (3.3V-5V DC range), screw mount, with load voltage and load current ranges for the AC devices you’ll control. One per device; I used 3 Crydom D1225 relays.
DC solid-state relays single-pull single-throw, logic-compatible input voltage (3.3V-5V DC range), screw mount, with load voltage and load current ranges for your DC devices.
Terminal block for 16- to 22-gauge wire
25-wire flat ribbon cable
25-contact male D-subminiature connector
with “displacement connection” that crimps onto ribbon cable
24-pin IDC DIP plug with displacement connection for connecting cable to breadboard
470Ω resistors one per relay, plus 1 more
LEDs Standard 2V are fine.
Small solderless prototyping breadboard
Stand-offs (4) to clear height of relays, with headroom for wiring
Nonconductive base I used plywood.
Nonconductive transparent cover I used a small sheet of hard acrylic.
Grounded extension cords One per AC relay. One should be at least 6′ long.
Wire 16-gauge stranded wire for AC devices, 22-gauge solid core for DC and signals.
Step 1: Assemble the controller board’s AC side.
My controller board has 3 AC relays (to power 120V AC props) and 2 DC relays (to power laser pointers and battery-powered props), but you can add another relay. These relays are switched on and off by signals sent from a personal computer through its parallel port.
The schematic here shows how the various components are connected. If you can’t read a schematic, don’t worry; you can still build the controller by following the photos. But to program it later, you’ll need to get into some simple C++ code and do some light tweaking, compiling, and debugging.
Attach main components to base. Lay the solid-state relays, terminal block, and breadboard onto the base as shown above. Mark and drill holes sized for the wood screws. Screw the components to the base.
Attach receptacles. Cut all the extension cords approximately 12″ from their receptacles, and strip ¾” of insulation at the cut. Mount 3 receptacles to the edges of the base by drilling through-holes and securing with cable ties.
Attach AC power cord. Attach the cut end of the fourth extension cord to the base, and strip ¾” of insulation.
Attach wires to terminal block. Wire up the AC side of the controller as shown, using the screw connections on the terminal block. Use short pieces of #16 wire to connect the hot side of each receptacle to the hot output (Terminal 2) contacts of the solid-state relays. It’s always best to switch the hot side, not the neutral.
TIP: The wires in extension cords are often color-coded: black is hot (live), white is neutral, and green is ground. If yours aren’t color-coded, look at the plugs with the blades pointing toward you and the round, ground plug at the top. Hot is the smaller blade, on the right, and neutral is the wider blade. Use a multimeter to test conductivity between the blades and wires to identify which is which.
Step 2: Make the data cable.
Snap D-sub connector to cable. Position one end of the ribbon cable squarely between the D-subminiature connector’s 2 rows of forked contacts, then press down to snap the connector into a locked position.
Snap DIP plug connector to cable. At the other end of the cable, peel 1 wire away from either edge (it doesn’t matter which). Connect the remaining 24-wire ribbon to the DIP plug, using the same method as above.
Determine pin-to-pin relationship. Use the multimeter to see which pins on the D-subminiature parallel port connector correspond to which pins on the DIP plug. The pins we’re interested in are the ones that connect to the parallel port’s output data lines (Pins 2-9), and the port’s grounds (Pins 18-25).
TIP: Sketch a map of the DIP plug’s layout or attach a label to help you remember.
Step 3: Wire up the board’s signal side.
Wire up the breadboard, then plug the DIP into it. Using the schematic or photos as a guide, wire up the controller’s signal side, using #22 wire. This will connect the relays’ input terminals to the parallel port via the ribbon cable, while LED/resistor pairs show the state of the parallel port.
The first output pin, Pin 2 on the parallel port, will always be on as a general status indicator. Then, starting with Pin 3 and going down the line, each input pin connects to both the positive-side input (Terminal 3) of each relay and the relay’s LED indicator. The other sides of the relay inputs and indicator pairs connect to ground.
Step 4: Connect the computer.
Secure the DIP connector to the board with a cable tie, so it won’t get yanked out.
Cover the AC portion of the controller. Mark and drill holes in the base and cover, and connect them with the stand-offs. I used clear acrylic so I could still see the LEDs.
Ensure that your wiring is correct before attaching the controller to a computer. A parallel port can only source a few milliamps of current, and can be damaged if the data lines are shorted to ground.
Plug the controller in to your computer’s parallel port (leave the AC unplugged for now) and see if you can illuminate the LEDs. Use a parallel port monitor such as lpt.exe from neil.fraser.name/software/lpt. The port number varies between machines, so be sure to check all options. You may have to change your parallel port’s setting in the BIOS to something other than bidirectional, such as ECP or output only.
NOTE: A parallel port’s 8 output pins are addressed in binary fashion: writing a 0 to the port turns them all off; writing 1 turns on only the first data pin (Pin 2); writing 2 turns on only the second data pin (Pin 3); 3 turns on the first and second, and so on up to 256, which turns on all 8.
Test the controller board by plugging it into 120V AC and then plugging a lamp into one of its AC plugs (Figure 4). The power to the lamp should now be under computer control.
Attach your devices. AC devices are simply plugged in. For a DC device, splice a DC relay’s output terminals between the positive wire that comes from the device’s power supply (for example, its wall wart) and its positive power input. For battery-powered devices, you can use an external battery pack and run the wires through the controller, or use an equivalent wall wart AC-to-DC transformer and plug that into the AC on the board.
Step 5: Create your action sequences.
Lights, strobes, fans, and fog machines are easy; just plug them in. Projectors shouldn’t be repeatedly power-cycled, but you can set up motors to block or deflect their beams. Motors with rotating cams will pull strings to make skeletons dance and bats flutter; reels will raise and lower hanging spiders. Laser pointers make creatures’ eyes come alive.
Think of simple but scary scenarios that can be conveyed by sounds and darkness, and enhanced by your devices. One approach is to weave a story just plausible enough that kids will wonder if it’s true, and while they’re pondering, startle them with something dramatic, like an abrupt lighting change or the hiss of a fog machine.
Create the soundtrack. Using a WAV file editor, I cut and pasted sounds from Halloween CDs. The sequence should suggest a series of events, but it needs to be short; trick-or-treaters aren’t known for long attention spans, and you don’t want the next group arriving in the middle.
Download Borland’s free C++ Compiler and then download inpout.dll and add it to your compile libraries. This is what makes calls to your parallel port from Windows NT and XP. For details and links, see hytherion.com/beattidp/comput/pport.htm.
Write the controlling code that syncs your devices to your soundtrack. Model your code on my sample at makezine.com/go/controller. Include the file inpout32.dll and define all of your devices as variables at the top of the file.
Now play your soundtrack file and run through a precisely timed sequence that pushes values to the parallel port (often at machine address 0x0378) and calls to the Sleep function. Compile, run, debug, and repeat as needed. Your haunted house is alive!
About the Author:
Eric J. Wilhelm got his Ph.D. in mechanical engineering at MIT, and currently runs Instructables (instructables.com), where he encourages people to share the projects they are passionate about.