PxT
Velvet Fog

Warning: electronics nerdery ahead!


This year for Halloween I impulse-bought a cheap $30 "The Fog Machine" brand fog machine at Target.  Catchy brand name!  It comes with an infrared remote to trigger the fog and the mist solution is water based.

It seemed like a good idea at the time but when I got it home, after accidentally filling the living room with a crazy amount of fog, I found that it can't be set to fog continuously or even on a timer.  To trigger the fog blast you have to either push a momentary contact button on the top of the machine or use the remote.  Turning it on with the remote give you an approximately 40-50 second blast of fog, or shorter if you push the remote again to stop it. 

Despite being labeled "for indoor use only" I wanted to recklessly disregard the warnings and have the machine outside on the walkway leading to our front door so that there would be a nice cloud of fog for the trick or treaters. However, pushing the button every so often was not really something I wanted to do.  So, being the nerd maker that I am, I hacked a solution.

I happen to have a bunch of electronics parts lying around from various prior projects so I decided that I could probably come up with a solution using an Arduino, a motion detector of some sort and an infrared LED.  I wanted the machine to set off a blast of  fog whenever it detected someone walking towards the entryway.  Timed right it could be scary, and also just having a nice cloud of fog floating around adds to the general spookiness of  Halloween.

For the motion sensor I used a passive infrared sensor (PIR). The LED is a standard IR model. I also used an IR receiver, temporarily, to decode the output from the fog machine's provided remote control.

The schematic for the final board looked something like this.  Not much to it.

And the breadboard:

To make it do something interesting I wrote a simple sketch to send out an IR code whenever the PIR detected some motion.  If you run the fog machine too often it will cool down too much and will have to cycle on the heater for a while before it can shoot fog again, so it is best to limit the rate at which it is turned on.  I found that a 6-second blast of fog (IR code, wait 6 seconds, IR code) cycled at most every 90 seconds produced a light haze in the air.  A 10-second blast every 20 seconds (at most) produced a huge cloud that covered my entire driveway and half the street in a thick fog.  

I loaded the board with the following sketch:

/*
* Trigger an IR fog machine based 
* on a motion sensor.  The fog 
* machine turns on for up to 40 
* seconds when it receives the IR
* code or until a subsequent IR 
* code is received, whichever comes first.
*/

/* Arduino IRSend library from 
 http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*/
#include <IRremote.h>
IRsend irsend;

/////////////////////////////
// VARS
/* the time we give the sensor to 
   calibrate (10-60 secs according
   to the data sheet)
*/

int calibrationTime = 20;

/* millisecond delay time between 
   activating the IR blast. 
   Fog will blast for this long
*/
unsigned long delayMillis = 6000;  

/* Time threshold which has to 
  elapse between successive fogging
*/
unsigned long thresholdMillis = 90000;  
/////////////////////////////


/* Captured from IRDump. This is 
   the remote control IR code that
   triggers the fog machine */
unsigned int powerOn[5] = {
4050,1950,1050,950,1050
};


/* the digital pin connected to 
  the Passive IR sensor's output */
int pirPin    = 4;

/* the digital pin connected to 
  the IR LED (must be 3)  */
int ledPin    = 3;

/* A normal LED (built-in on the 
  Uno), used to show that the 
  motion sensor is working */
int statusPin = 13;  

void setup()
{

    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    pinMode(statusPin, OUTPUT); 
    digitalWrite(pirPin, LOW);
    Serial.begin(9600);
    // give the sensor some time to calibrate
    Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
        Serial.print(".");
        digitalWrite(statusPin, HIGH);
        delay (250);
        digitalWrite(statusPin, LOW);
        delay(750);
    }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);

}


void loop() {

    if(digitalRead(pirPin) == HIGH){

        // Turn on visible LED
        digitalWrite(statusPin, HIGH);
        Serial.println("---");
        Serial.print("motion detected at ");
        Serial.print(millis()/1000);
        Serial.println(" sec"); 

        /* Send IR code to trigger the machine */
        Serial.println("Sending IR code");
        irsend.sendRaw(powerOn,5,38);
        delay(delayMillis);
        /* send the same code to turn it off again */
        Serial.println("Sending IR code");
        irsend.sendRaw(powerOn,5,38);

        // Turn off visible LED
        digitalWrite(statusPin, LOW);
        delay(thresholdMillis);
   }

}


I folded the breadboard shown above over onto the back of the Arduino so that it was a neat little bundle and taped the two halves together. Then I aimed the LED at the receiver on the fog machine and the PIR at the driveway where kids would be approaching the house.  I plugged the whole contraption in and presto!  Instant (almost) motion-controlled fog.  

I got a ton of comments from the free-loading, candy-seeking, kids about how they loved the fog.  Most of them thought it made the house seem spooky, especially the younger ones who tended to be scared of it.  The older kids were impressed.  All in all, it was a big hit and pretty fun to put together.  Improvements for next year could include some throttling on the motion sensor.  It was a bit too eager on the trigger and the slightest little thing would set it off.  That could be solved in software by waiting for several consecutive readings before sending the IR code.