Sunday, November 2, 2014

Arduino Controlled Halloween Light/Sound/Smoke Effects

    As mentioned in the previous post, I had been working on some Halloween effects with the kids this year.  The last post discussed the digitally controlled smoke machine I created to make this project possible.  This post seeks to discuss the rest of what we put together.


    Using an Arduino, we were able to set up an IR beam to act as a motion detection trigger.  When the beam between the two is unbroken, the Arduino controls an AC socket, powering a friendly Jack-o-lantern and porch light.  Once the IR beam become broken, the Arduino:

  • kills power to the AC socket, extinguishing the lights,
  • starts the smoke machine, and
  • sends a message to my MacBook, causing the MacBook to start playing back spooky sound effects.

After a delay of 3 seconds, the Arduino:

  • turns on LED circuits 1 and 2, lighting up the eyes of an evil looking Jack-o-lantern.

After a delay of 27 seconds (total elapsed time is 30 seconds), the effect is considered over.  Correspondingly, the Arduino:

  • turns off LED circuits 1 and 2,
  • stops the smoke machine, and
  • turns power back on to the AC socket, lighting the friendly Jack-o-Lantern and porch light back up.
To whet your appetite,  I've included a clip of our first test in the basement of my house.  A discussion of how to build the system starts after the jump.

Bill of Materials

    Here is what it took for me to get this off of the ground (note that because of the quick turn nature of the project, I leaned heavily towards equipment I already had on hand or could easily get):

Arduino Uno R3$24.95
Adafruit Half-sized PCB Protoboard$4.95
Powerswitch Tail2$25.95
Screw-down terminal blocks$9.54
Project Box$2.98
250 ft 18 AWG Brown lamp cord$44.40
High Intensity Blue LED x 2$5.58 ($2.79 ea)
IR LED Emitter and Detector$3.99
Digitally controlled smoke machine (previous project)$60 (approx)
Halloween Decorationsvaries
Miscellaneous LEDs, Resistors, Wires$10
TOTAL$195 (give or take)

Connecting it all Up

    Here is the circuit diagram diagraming everything:
    On the left is the Arduino Uno.  All of the pins from the Arduino route to the protoboard, where all of the resistors and LEDs on the left side of the diagram are located.  The protoboard then routes to the screw down terminal block, where it interfaces with (starting from the top) the IR detector circuits, smoke machine, AC circuit (via PowerSwitch Tail 2), and LEDs.  Not depicted is the USB cable used to for power and serial communications.

    And here's how it looks all wired up in the project box:
Project Box - Arduino Uno (left) wired to  protoboard (right) in turn wired to terminal block (screwed into right side of the box)

Arduino Code

    If you've never used an Arduino before, do not fret.  They are amazingly easy to use.  Please visit this page for all the information you'll need to get started.
    As with all good projects, I started by googling for similar projects; specifically with regards to IR sensors (as the rest of the project seemed fairly straight forward to me).  Ultimately, I settled on this project over at Instructables as a basis for mine.  Please be sure to visit that page for tips on how to assemble the IR sensor/detector portion of the circuit.  
    Starting with the Instructables code, I then defined additional pins for the devices I wanted to control and then an animation subroutine to be run when the IR beam is broken.  The complete code can be found here:  

Computer scripts

    Once the Arduino is programmed and calibrated, the circuit will handle motion detection via the IR beam and the resulting lighting/smoke effects on its own.  However, if you want associated sound effects, a computer will be required.  In my case, that computer is a late model (2007) MacBook with iMovie HD installed.  The scripts I used to enable sound effects are relatively simple and can be found here:  
    There are two scripts total.  A perl script ( opens up serial communications with the Arduino, listening for a trigger event.  Once the trigger is received, a bash script ( is started to produce the sound effects.  Note that both scripts are very set-up dependent(Mac OSX with iMovie HD installed).  In order to enable your own sound effects, you will likely have to edit the scripts at least a little bit.

Final assembly

   Once the project box is wired up, the Arduino programmed and scripts installed, all that remains is to deploy everything.  To do so:
  • Connect the computer to the Arduino via a long USB cable.  Attach and position speakers (to amplify the sound effects), if so desired.  
  • Locate the project box in some inconspicuous but central location.  
  • Place each of the effects (smoke, LED, AC outlet) in their desired location.  Connect each effect to  the project box via appropriately sized runs of wire, being mindful to keep the positive and negative ends of the circuits straight.
  • Calibrate the IR beam again, if needed.
  • Enjoy
    In my setup, we had a porch lantern and friendly jack-o-lantern installed on the AC Circuit.  A number of the foam tombstones were set up as a small graveyard and an less friendly jack-o-lantern was placed amongst the stones, with both LEDs used to illuminate the eyes of the jack-o-lantern.  The smoke machine was placed within the graveyard to cover the tombstones, ensuring the less friendly jack-o-lantern was covered in plenty of smoke.  Lastly, speakers were placed in the adjoining window for sound effects.  Here is a video of one of the last tests we did prior to halloween commencing (Please note where everything is on the title screen, the movie itself is not well illuminated; also one LED and sound effects were not wired in for this test):

    Unfortunately we lost the light before we got everything up and running (so a full video was not feasible).   However, we were able to get everything working and received many positive comments from trick-or-treaters and parents regarding the effects.

Issues with deployment

    As you might expect, not everything went to plan.  The biggest issues had to do with the IR beam.  Originally, we had planned on do a beam crossing the entrance to the porch.  Unfortunately, that seemed to be a bit too far for reliable operation of the beam (especially before night fall).  Rather than deal with an unreliable trigger, we quickly reconfigured to put the trigger around the frame of the door, triggering when the doorbell is rung.  That worked much more reliably, although it did require at least one recalibration.
    The other major issue we had was with recalibration.  As night fell, the IR transmitter  quickly became easier for the sensor to see, resulting in our threshold being far too low to trigger at night.  Thankfully we were able to very quickly recalibrate (a manual process), returning the trigger to reliable service in short order.


    All in all, everything seemed to work fairly well and we received many positive compliments on the setup.  We are currently in the process of mothballing everything for next year, at which point we'll pull it out again and hopefully improve on the design.  Comments/suggestions?  Please feel free to leave them in the comments section below.  Thanks for reading.

No comments:

Post a Comment