Introduction: Control a Fog Machine With Your Microcontroller

Fog machines are lots of fun, especially at Halloween.  But the ones you can get at most party stores either come with a basic remote that means you have to push a button to get a blast of fog, or they have a remote with a built-in timer, which blasts fog all night every few moments...even if no one is there.  And then you run out of fog juice.

I'll show you how to make a replacement for the standard remote that you can control with any microcontroller (Basic Stamp, Arduino, Picaxe, EFX-Tek Prop-1, etc.)  I'm going to assume you know how to program and connect your microcontroller.  This Instructable is about making the control box for the fog machine.

You could just use a motion sensor and a microcontroller to blast kids with fog as they came up to get candy, but this also lets you incorporate the fog machine into a more elaborate scene...trigger a sound effect, a light, or a moving prop, and include a blast of fog as well.

Step 1: Parts and Tools

Parts: 
1x 5V Relay Module – www.dx.com SKU: 157153
1x IEC extension cable – this will connect to your fog machine.
1x Project box - comes with screws to hold it closed in a small plastic bag.  Jameco Part no. 675462
1x Stereo plug  Jameco Part no. 231176
1x Stereo jack  Jameco Part no. 2095437
4x Screws 4-40, 1/2”
4x Nuts 4-40
1x 1” piece of plastic tubing, ¼” outside diameter, for stand-offs
1x Servo extension cable – connects the relay to the stereo jack
1x 3-wire cable – connects the stereo plug to the controller, 12” or more if needed
1x zip tie
Heat shrink tubing

The parts list is attached as a handy Excel file, with part numbers and websites.  You can substitute similar parts for many of these.


Tools Required:
• Soldering iron
• "Helping Hands". You can make one yourself, check these out:
https://www.instructables.com/id/DIY-Helping-Hands-Cheapest-and-Quickest/
• Wire clippers
• Wire strippers
• Small flat blade screwdriver
• Small Phillips screwdriver
• Small needle-nosed pliers
• Tweezers
• Hot Glue gun and sticks
• Exacto knife and something to cut on (small board, etc)
• Multimeter
• The remote from your fog machine
• Power drill with assorted bits
• Hot air gun or hair dryer (for heat shrink tubing)

Step 2: Overview

Here’s what it will look like when it’s done.  The relay will be mounted inside the project box.  The connection to the prop controller plugs in on the left, and the cable to the fog machine connects to the relay on the right.  Once this is assembled we’ll hot-glue everything in place so it won’t move, and so water can’t get in, and then screw the top on.

Why am I taking this much trouble on this project?  It’s because the remote control that comes with these foggers has line voltage running through it.  Now this is standard, many hand-held household appliances work this way (hair dryers, steam irons, etc.) but since we’re going to use this where it’s out of sight, at night, I wanted to make things as safe as possible.  So we’re sealing the relay inside a small box and using hot glue to keep water from getting in.

About the relay: When I wrote this, these pre-made relay boards had become pretty common and were available from a lot of different vendors, ready to connect to your favorite microcontroller.  The one I picked has a feature called “optoisolation” which means that the high voltage is electrically isolated from any wires going back to your microcontroller.  (See Wikipedia for a big article.)  If you can’t get this exact module, I suggest you order what you can with the same features and then find a project box to fit it.

Step 3: Preparing the Project Box

We need to drill holes to mount the relay and for the IEC cord and the stereo jack.

Relay – Notice in the picture that the relay isn’t dead center in the project box, but it’s over to the side a bit.  This allows space for the stereo jack and the wires.  Hold the relay in place and mark the holes for the standoffs with a pointed object in the bottom of the box.  Then drill holes using a 7/64” drill bit (this is just right for 4-40 screws).

IEC cord – Drill a hole with a 5/16” bit in the side wall.  This is on the right in the picture above.

Stereo jack – This is a bit tricky, the only jacks I could find didn’t have a long neck.  So I drilled a hole for the neck and then counter-sunk a slightly wider hole partway into the plastic for the nut on the neck.  I used a stepped drill bit and went in just enough so there was room for the nut.  See picture.

Step 4: Color-code the Wires, and Check the Relay

I’ve color-coded the wires so that they follow standard conventions: Black for GND, Red for 5V and White for signal. 

The connections in the next few steps follow those colors, and this makes it easy to hook up to your microcontroller (and troubleshoot if necessary).  But…check the connections on the relay.   If you look closely at the picture, you’ll see that this specific relay board does NOT follow the pattern that the red/black/white wires do!  I had to use a very small screwdriver to pry up the fingers on one end of the servo connector for red and black, pull them out, and swap their positions.  Then cut the servo connector wire so you have about 3” of wire extending from the plug.

Now it’s time to solder.  There are only six connections to solder but they can be kind of finicky.

Step 5: Solder the Stereo Plug

Take the 3-wire cable (12 inches long, White/Red/Black), and strip the ends.  Unscrew the plastic cover from the plug, and solder the wires onto the lugs, following the diagram (the solder lugs are on the left).  Make sure to run the wires down the middle of the lugs, not on the outside, so they’ll fit into the plastic cover later.

When you're done, test the connections: Use the multitester to check for shorting between wires, and to check the wires connect to the right parts of the plug.  Use pliers & crimp the wings on the black lug lightly around the wires.  Make sure you don’t short any parts of the plug together.

Step 6: Solder the Stereo Jack

Take the servo extension cable (White/Red/Black with the rectangular connector on the end) and strip the ends of the wires.  Put small sections of heat shrink tubing onto the wires.  Solder them to the stereo jack like this (the diagram is the back side of the jack).

Step 7: Test the Connections

Plug the stereo plug into the jack, and use the multitester to confirm that white on one end connects to white on the other end, and the same for the other two colors.  Also make sure there are no shorts between the colors.

When you’re satisfied it’s all correct, put the plastic sleeve back onto the stereo plug, and hit the heat shrink tubing with hot air to insulate the connections.

Step 8: Make the Standoffs

I got this idea here, check this blog for pictures:
http://store.curiousinventor.com/blog/make-cheap-standoffs-with-nylon-tubing

Using the Exacto knife, cut the small section of plastic tube in half.  Then cut each half in half again, so you have four short pieces the same length.

Step 9: Install the Relay Into the Project Box

This part will require a little eye-hand coordination.  Get the:
- Project box
- Screws (4-40, ½ inch long)  (These are NOT the screws used to hold the project box lid in place.)
- Nuts (4-40)
- Plastic tube sections
- Relay

Put the screws into the holes on the relay board, and then thread the plastic tube sections onto the screws.

Now here’s the eye-hand coordination part: Push the screws through the holes in the bottom of the project box (without losing the plastic tubes!)  Make sure you orient the relay the right way, so the screw terminals face the big hole for the IEC cable. 
When they’re through the holes in the bottom, put the nuts on the ends of the screws and tighten.  If the screws don’t stick out far enough, you may need to trim the plastic tube sections a bit.

Step 10: Screw in the Stereo Jack

Unplug the stereo plug from the jack, take off the nut on the end of the jack and put the nut into the countersunk hole on the outside of the box, then put the jack in the hole inside the box and spin the jack around to lock it in place.

Step 11: Plug the Rectangular Servo Connector Into the Relay Board

The colors should go this way:

Red – VCC
Black – GND
White – IN

Again, you may need to swap the connectors so the colors match.

Step 12: Testing

Plug the stereo jack into the plug. At this point the relay can be controlled by your microcontroller.  You can connect it up and try triggering it (see the section on the code). 

Most relay modules have an LED that shows it’s getting power from the microcontroller, and another LED to show that the relay is activated (along with a “click” when it’s on).  It’s easy to connect to your microcontroller: Black to GND, Red to 5V, White to the pin. 

If your microcontroller can turn the relay on and off, you've finished the first half.  Now to test and wire up the connection to the fog machine.

Step 13: Test Your Fog Machine Remote

At this point we want to check what connections your fog machine uses.  Most fog machines on the market use the same cable, but there are some variations out there.  If yours is different you can still test your remote the same way and then find a surplus cable with the right connector to adapt.

Look at the end of the cable which plugs into your fog machine, and verify which parts of the plug are connected to the switch.  One person can hold the multitester leads to the connections while another can press the button on the remote.  Tip: Hold your multitester leads like chopsticks with one hand; use the other hand to hold the plug.  Touch the ends to the prongs of the plug, and have someone press the button.  Only two of the prongs should show a connection when the button on the remote is pressed.

Step 14: Prep the Fog Machine Cable

Cut off the solid end of the cable (the one that does NOT match the one on your remote!)

Strip the wires.  Then test the connections so that you know which colors of wire in your cable connect to the switch, using what you just learned.  In the cable I used, these were Yellow/Green and Blue wires, while the Black one wasn’t needed.  Cut that one off.

Step 15: Connect the Fog Machine Cable, Then Test It

Run the ends of the IEC cable into the project box through the remaining hole, and screw it into the Common and the Normally-Open connector (on this relay module, these are the center and the bottom).

Then test it with the fog machine.  This is the last electrical connection!  You previously verified that you could trigger the relay with your microcontroller.  You can now plug the cable into your fog machine and try triggering it with your microcontroller. 

A blast of fog = success!

Step 16: Close It Up!

Zip tie the IEC cable in place:  Put the zip tie around the IEC cable on the inside of the box, right up against the plastic, where it comes through the hole.  This will act as strain relief in case someone trips over the cable.  Make it tight and cut off the long end with the clippers when you’re done.

Hot Glue everything.  Now that it’s all working, we want to make sure everything stays in place and water can’t get in.  Put a blob of hot glue on the following (marked by red arrows in the picture):
a. Stereo jack, so it doesn’t turn.
b. Standoffs under the relay, so they don’t unscrew.
c. Servo connector where it plugs into the relay, so it can’t come out (unlikely, but why not?)
d. IEC cable to the fog machine.  Use a LOT where it comes inside the box – we want to make sure water can’t come in.  Put some around the outside, too – make a little “collar”.

Finally, put the top on and use the little bag of four screws to screw it closed.

Step 17: Connecting to a Prop Controller

The ends of the wires coming out of the stereo plug have been color-coded so it’s easy to connect them to any prop controller.
Black = GND
Red = 5V
White = Signal (the pin on the controller that will trigger the relay)

The basic code is very simple.  The white wire goes to one of the output pins on the microcontroller.  Drive that pin HIGH for two or three seconds when you want a blast of fog.

The zip file attached includes example code for EFX-Tek Prop-1 (Basic Stamp 1), and Arduino. 

The Basic Stamp code is a demo, just to show how a button press will tell the microcontroller to trigger the fog machine.

The Arduino code is written to respond to a PIR motion sensor, and then to control three relays, so it acts like a "Three-Stage Timer".  It's good for controlling a bunch of things that go off together.

Have fun!

Weekend Projects Contest

Participated in the
Weekend Projects Contest

Halloween Decorations Contest

Participated in the
Halloween Decorations Contest