Introduction: Halloween Hack: Ghost Clyde

Clyde masquerades as a ghastly ghost in this Halloween Hack. Ghost Clyde has a few tricks up his sheet: a motion sensor and a computer fan add some spooky responsive behavior. Program Clyde to flutter his sheet and his lights when the motion sensor is triggered. LED Apparitions!!


In this tutorial you'll learn: how to create a spooky paper mask for Clyde; how to build a circuit using a resistor, a diode and a transistor to drive a computer fan; and how to trigger custom Clyde's behavior using a PIR motion sensor. This tutorial is presented in four steps. You'll start with the paper mask, then the fan circuit, and the motion sensor and finally programming Clyde's ghostly behavior. Let's get started!

The Steps

Step 1: Make a ghost face mask for Clyde

Step 2: Build the fan circuit

Step 3: Connect the motion sensor

Step 4: Program Ghost Clyde's spooky behavior

What you’ll need

Ghost Clyde in Action

A note about wind power:

The 12v computer fan does not produce very much wind power. If you use the fan, Ghost Clyde will have a very subtle flutter. Some people like subtle things, others prefer to be bashed over the head with the obvious. So, if you want more of an impact you are free to try alternate wind power sources, like this 12v squirrel blower from Sparkfun:

Follow Fabule on Facebook and Twitter us to see what Clyde is up to these days for Halloween.

Step 1: Make a Ghost Face Mask for Clyde

You'll need card stock, a knife, scissors and tape. Start by drawing a ghost face on a plain piece of paper. I made two: a scary jack o' lantern face and a more classic howling ghost face. Cut the face from the piece of paper with scissors. This will be your pattern.

Tape the face pattern to the card stock. Cut out the eyes and mouth with the exacto knife.

Draw notches around the edge of the pattern. Draw a circle about 1 inch out from the edge of the pattern edge. These notches will allow you to fit this flat piece of paper onto Clyde's round dome.

Cut out the paper mask. Follow along the circle you just drew. Cut the notches out carefully. Watch that you do not cut to far into the mask when you cut the notches. Cut up until the edge of the original mask pattern. Bend the notches in slightly.

Tape the mask over Clyde's eye button.

Plug Clyde in and see the results.

Now check it out with the lights out. Cool, right!?

Step 2: Build the Fan Circuit

In this step you'll build the simple circuit using the fan, mini breadboard, resistor, diode, transistor and the male/male jumper wires.

Before you begin, take a moment to review the fan circuit illustrated in the diagrams. These diagrams were created using Fritzing, a free simple electronics documentation software.

In the first breadboard diagram, you may not have noticed but the transistor obscures part of circuit. For this reason I've included a second breadboard diagram with the transistor lifted, so you can see what is happening behind the transistor.

Add the 1K ohm resistor to the breadboard. Connect one lead with a jumper wire, and the other to transistor's base pin. Connect a jumper wire to the transistor's emitter pin.

Flip the breadboard around. Add the diode. The ringed end of the diode connects to the transistor's collector pin. The other side of the diode connects to emitter pin.

Add 2 jumper wires to one row of the breadboard, shown here with the red jumper wires. One of these jumper wires will connect to the fan and the other to the VIN pin on the board.

Connect jumper wires to the fan. Connect the fan's + wire, (the red one), to one of the jumper wires that you just added to the breadboard (one of the red ones). Connect the fan's ground wire to the jumper wire connected to the transistor's collector pin (the middle one).

Connect the the other red jumper wire to VIN pin on Clyde's board. Connect the jumper wire on the transistor emitter pin to GND. Connect the jumper wire on the resistor to pin 13.

Nice work. The fan portion of the circuit is complete. You can jump ahead to the code to test this and make sure it works.

Step 3: Connect the Motion Sensor

The motion sensor does not require any additional electronic components to work with Clyde. It needs to be wired to Clyde's board. You'll need the PIR motion sensor and the female/male jumper wires.

Connect the female/male jumper wires to the motion sensor.

Connect the GND wire to the GND pin on Clyde's board. Connect the +5V wire to the +5v pin.

Connect the signal wire to pin 10.

Congratulations! The circuit is complete.

Put Clyde's lid back on. The wires for the fan and the motion sensor need to fit between the lid and the base. This can be a bit difficult, you'll have to make sure that the lid is properly aligned with the base and then carefully press the lid down.

Stand Clyde up and place the fan and the motion sensor at his feet.

Attach the motion sensor to one of Clyde's feet with the zip tie.

Place a small white sheet over Clyde's head. Make sure the motion sensor is sticking out.

Ghost Clyde is almost ready to terrify! You need to program Clyde to work with the circuit you just constructed.

Step 4: Program Ghost Clyde's Spooky Behavior

Copy and paste the following code into your Arduino IDE. Upload to Clyde and let the hauntings begin!

The code is also available on GitHub gist:

<p>/*<br>  Ghost Clyde
  Halloween Hacks
  Fabule Fabrications
  by Angela Gabereau
  Oct 21, 2014
 Motion triggers the haunting, Clyde's eye light turns on, and the task light 
 and fan fade in and out several times, then the ghost goes silent again. 
 Arduino's basic fade example was the starting points of this code.
int taskLight = 11;           // the pin that Clyde's task light is attached to
int fan = 13;           // the pin that the fan is attached to
int R = 5, G = 6, B = 9;    // the pins for the red, green and blue of the Clyde's eye light
int rColor = 255, gColor = 255, bColor = 255;  // The color values for the R,G amd B pins</p><p>int pirPin = 10;    //the digital pin connected to the PIR sensor's output
int calibrationTime = 30;   //the time we give the sensor to calibrate (10-60 secs according to the datasheet) 
boolean haunting = false;       // should the task light and fan fade in and out and the eye light turn on.
int spookCount = 0;  //The number of times the spooky light/fan cycle has run since trigger.
int spookLimit = 3;  //The number of times the spooky light/fan cycle runs on trigger.
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by</p><p>// the setup routine runs once when you press reset:
void setup()  { 
  //Initialize pins.</p><p>  // Declare Clyde's task light pin to be an output:
  pinMode(taskLight, OUTPUT);
  // Turn off Clyde's task light by setting pin high.
  digitalWrite(taskLight, HIGH);</p><p>  // Declare fan pin to be an output:
  pinMode(fan, OUTPUT);
  // Turn off fan by setting pin low.
  digitalWrite(fan, LOW);</p><p>  // Declare R,G and B pins to be outputs, for Clyde's eye light.
  pinMode(R, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(B, OUTPUT);
  // Turn Clyde's eye light red to show that it is calibrating.
  digitalWrite(R, 255);
  digitalWrite(G, 0);
  digitalWrite(B, 0);</p><p>  calibrateMotionSensor();
  // turn Clyde's eye light off to show that calibration is complete
  digitalWrite(R, 0);
  digitalWrite(G, 0);
  digitalWrite(B, 0);
} </p><p>// The loop routine runs over and over again forever:
void loop()  {</p><p>  // Does Ghost Clyde perform his haunting behaviour?
    // Fade light and fan.
    // Check if the spooky light and fan fading cycle has run enought times.
      // Who you gonna call?!
}</p><p>//  Fade Clyde's task light and fan, turn on his eye light.
void spookyClyde(){</p><p>  // Set Clyde's eye light to color
  digitalWrite(R, rColor);
  digitalWrite(G, gColor);
  digitalWrite(B, bColor);</p><p>  // Set the brightness of the task light:
  analogWrite(taskLight, 255-brightness);
  // Set the brightness of the fan:
  analogWrite(fan, brightness);  </p><p>  // Change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;</p><p>  // Reverse the direction of the fading at the ends of the fade: 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }</p><p>  //A moment of darkness.
  if (brightness == 0){
  }</p><p>  // Wait for 30 milliseconds to see the dimming effect    
}</p><p>// Turn off all haunting behavior.
void ghostbusters(){
  // Reset haunting values.
  haunting = false;
  spookCount = 0;</p><p>  // Turn Clyde's eye light off
  digitalWrite(R, 0);
  digitalWrite(G, 0);
  digitalWrite(B, 0);</p><p>  // Turn off Clyde by setting pin high.
  digitalWrite(taskLight, HIGH);</p><p>  // Turn off fan by setting pin low.
  digitalWrite(fan, LOW);
}</p><p>//Wait a little while so that the motion sensor can calibrate.
void calibrateMotionSensor(){</p><p>  for(int i = 0; i < calibrationTime; i++){
}</p><p>void checkMotionSensor(){
  //If the PIR pin is high, trigger the haunting behavior.
  if(digitalRead(pirPin) == HIGH){
      haunting = true;      

Step 5: Scare People!

Now Ghost Clyde is ready to haunt your family, friends, neighbors and colleagues!

Be sure to check out the Ballerina Clyde Halloween Hack on the Fabule Blog:

Don't forget to share your Clyde Halloween Hacks with us! We have a Clyde Halloween Costume Contest until Nov 10th 2014. Learn more about it here:

Follow Fabule on Facebook and Twitter us to see what Clyde is up to these days for Halloween.

Happy Halloween from the Fabule Team!

Halloween Decor Contest

Participated in the
Halloween Decor Contest