Introduction: Arduino Powered Haunted Pumpkin

This is a cute little project that takes a pumpkin, motion sensor, and some parts from Radio Shack. It was fun to create and build. This project was sponsored by the Radio Shack Great Create and I was able to make the whole thing with parts available from Radio Shack. Thanks for the gift card, Radio Shack!


Step 1: Parts

Arduino Uno

9V Recording Module
http://www.radioshack.com/product/index.jsp?productId=2102855
$10.99

MPS2222A Transistor
http://www.radioshack.com/product/index.jsp?productId=2062608
$1.19

150 ohm resistors (5 pack)
http://www.radioshack.com/product/index.jsp?productId=2994582
$1.19


(2) 10MM high brightness red LED two-packs (total of 4)
http://www.radioshack.com/product/index.jsp?productId=3096133
(2*$2.19) $4.38

10mm High-Brightness White LED
http://www.radioshack.com/product/index.jsp?productId=3125355
$3.19

PIR Sensor Module
http://www.radioshack.com/product/index.jsp?productId=2906724
$10.19

Total cost of Radio Shack parts: $31.13


These other parts are good to have handy:
Heat shrink tube: http://www.radioshack.com/product/index.jsp?productId=2102875
Digital multimeter: http://www.radioshack.com/product/index.jsp?productId=2103176
22 ga. solid hookup wires: http://www.radioshack.com/product/index.jsp?productId=2049745
Zip ties: http://www.radioshack.com/product/index.jsp?productId=2103326

Solder and soldering iron.
Hot Glue

Step 2: The Circuit




This circuit is relatively simple. The red LEDs are attached to digital pins on the Arduino through the resistors. The white LED goes to Pin 13 (no resistor needed given the voltage and duty cycle of the LED) and the motion sensor and voice module are given their own digital lines as well.

It is important that the two "glowing eyes" LEDs are attached to PWM pins on the Arduino so they can properly fade. I used Pin 3 and Pin 5.

Step 3: LED Tips

To keep this project simple, I soldered the resistors for the LEDs "in line" with the wire, shown in this photo. Heat-shrink tube adds both stability and insulation to the circuit.

Step 4: Hacking the Voice Module


The voice module required a transistor to trigger the button. The video and photo attached show how to use the transistor in the parts list to trigger the button from an Arduino pin.

Extra special thanks to Paul at Radio Shack #01-3209 in Santa Clara for suggesting this and other parts.

Step 5: The Source Code

This code loops the "brightness up" and "brightness down" on the LEDs, checking for motion at the top and bottom of the cycle. If motion is detected, it calls the "freakout" function causing the blinking and laughter. That's all!

/*
This is the source code for the motion sensitive
haunted pumpkin built for Radio Shack.
Original code by Daniel Gentleman, thoughtfix.com
*/

// Set up pin assignments
int leftEye = 3; // PWM pin 3
int rightEye = 5; // PWM pin 5
int redBlink1 = 9;
int redBlink2 = 10;
int whiteBlink = 13;
int laughBox = 12; // transistor to voice module
int pirSensor = 7; // passive infrared sensors
int pirState = 0; //Initial IR state

// Setting up pin modes
void setup() {
pinMode(leftEye, OUTPUT);
pinMode(rightEye, OUTPUT);
pinMode(redBlink1, OUTPUT);
pinMode(redBlink2, OUTPUT);
pinMode(whiteBlink, OUTPUT);
pinMode(laughBox, OUTPUT);
pinMode(pirSensor, INPUT);
}

void loop () {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(leftEye, fadeValue);
analogWrite(rightEye, fadeValue);
// wait for 30 milliseconds
delay(30);
}
pirState = digitalRead(pirSensor); // read the state of the pirsensor value:
if (pirState == HIGH){ // If motion is detected
freakout(); // Call the freakout routine
}

// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(leftEye, fadeValue);
analogWrite(rightEye, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
pirState = digitalRead(pirSensor); // Same as above
if (pirState == HIGH){
freakout();
}

}

void freakout(){
digitalWrite(laughBox, HIGH); // Send intial ON for all pins
digitalWrite(leftEye, HIGH);
digitalWrite(rightEye, HIGH);
digitalWrite(redBlink1, HIGH);
digitalWrite(redBlink2, HIGH);
digitalWrite(whiteBlink, HIGH);
delay(250);
digitalWrite(laughBox, LOW); // turn off laugh button
for (int i=1; i<=40; i++){ // Start blinking mayhem
digitalWrite(leftEye, HIGH);
digitalWrite(rightEye, HIGH);
digitalWrite(redBlink1, LOW);
digitalWrite(redBlink2, LOW);
digitalWrite(whiteBlink, LOW);
delay(50);
digitalWrite(leftEye, LOW);
digitalWrite(rightEye, LOW);
digitalWrite(redBlink1, HIGH);
digitalWrite(redBlink2, HIGH);
digitalWrite(whiteBlink, HIGH);
delay(50);
} // Finish blinking mayhem, turn everything off
digitalWrite(redBlink1, LOW);
digitalWrite(redBlink2, LOW);
digitalWrite(whiteBlink, LOW);
}

Step 6: Installation, Testing, and Completion.

I used a USB battery which should offer plenty of run time for such a simple circuit. An artificial pumpkin, hobby knife, and hot glue did the rest.

Be very careful with your wiring as too much tugging can yank the wires out. There should be no harm done in leaving the circuit running while going through the hot glue and installation tests.

Below are two videos of the pumpkin in action:





Halloween Decorations Challenge

Finalist in the
Halloween Decorations Challenge

Make It Glow Challenge

Participated in the
Make It Glow Challenge