Motion Activated Halloween Spider
by StumpChunkman in Living > Halloween
10143 Views, 27 Favorites, 0 Comments
Motion Activated Halloween Spider
We're running a special series of custom Instructables for Ace Hardware, an advertiser on Instructables. This is the first of three awesome projects we've created in-house using parts from our local Ace store.
I wanted to create a motion-activated spider to put on my door for Halloween. It drops down when visitors approach the entryway, activates a spot light to draw their attention to the spider, gives them a scare, then automatically retracts and resets itself, waiting to prey upon its next victim.
I used a basic motion sensor light from Ace Hardware to activate my spider. Of course, I could have just bought a commercial product from the store, but this is a great excuse to learn about some basic electronics and programming procedures, and this platform allows me to drop anything I'd like on unsuspecting visitors, with complete Arduino-controlled customization!
I wanted to create a motion-activated spider to put on my door for Halloween. It drops down when visitors approach the entryway, activates a spot light to draw their attention to the spider, gives them a scare, then automatically retracts and resets itself, waiting to prey upon its next victim.
I used a basic motion sensor light from Ace Hardware to activate my spider. Of course, I could have just bought a commercial product from the store, but this is a great excuse to learn about some basic electronics and programming procedures, and this platform allows me to drop anything I'd like on unsuspecting visitors, with complete Arduino-controlled customization!
Materials
Our local Ace Hardware has a section full of motion activated lights, which seemed the perfect actuators for a Halloween surprise.
I settled on a simple project that would help me get some basic electronic experience, and started searching for parts. Ace is close to home, and there's a Radio Shack in the same plaza, so the materials I needed were easy to find. Most of the stuff I had lying around the house, but I'll try to provide links so it makes more sense.
In addition to the Motion Activated Light, my materials included the following:
Lightbulb Socket to Female Wall Plug Connector (referred to as light plug from now on)
Electrical Tape
Solderless Breadboard
Assorted Solid Core Wires
Wire Connectors
ULN2003A IC (ordered from Jameco)
Arduino Diecimila (and USB Cord)
Circuit Board
Box Cutters
Drill
1 LED
Super Glue
Double Sided Sticky Tape
A Sewing Bobbin (craft store)
[http://www.acehardwareoutlet.com/(4cmx3x5521lr3m5544z52zrs)/ProductDetails.aspx?SKU=8004285 Fishing Wire]
Wall Power Adapter to power Arduino (or 9V Hookup)
Wall Power Adapter to trip Arduino
Basic Extension Cord
3x5 Note Card Box (that I had broken and lying around for housing)
Stepper Motor (Mine is from an old disk drive)
Spider
Feel free to substitute anything you need...a lot of these are very general and can easily be switched with another tool.
My end goal: to program the Arduino to slowly lower the spider when someone walked up to the house, light it up when it was at eye level, and then raise it back up into its web, awaiting its next victim.
I settled on a simple project that would help me get some basic electronic experience, and started searching for parts. Ace is close to home, and there's a Radio Shack in the same plaza, so the materials I needed were easy to find. Most of the stuff I had lying around the house, but I'll try to provide links so it makes more sense.
In addition to the Motion Activated Light, my materials included the following:
Lightbulb Socket to Female Wall Plug Connector (referred to as light plug from now on)
Electrical Tape
Solderless Breadboard
Assorted Solid Core Wires
Wire Connectors
ULN2003A IC (ordered from Jameco)
Arduino Diecimila (and USB Cord)
Circuit Board
Box Cutters
Drill
1 LED
Super Glue
Double Sided Sticky Tape
A Sewing Bobbin (craft store)
[http://www.acehardwareoutlet.com/(4cmx3x5521lr3m5544z52zrs)/ProductDetails.aspx?SKU=8004285 Fishing Wire]
Wall Power Adapter to power Arduino (or 9V Hookup)
Wall Power Adapter to trip Arduino
Basic Extension Cord
3x5 Note Card Box (that I had broken and lying around for housing)
Stepper Motor (Mine is from an old disk drive)
Spider
Feel free to substitute anything you need...a lot of these are very general and can easily be switched with another tool.
My end goal: to program the Arduino to slowly lower the spider when someone walked up to the house, light it up when it was at eye level, and then raise it back up into its web, awaiting its next victim.
Prepping the Light Part 1
The first thing I needed to do was prep the Ace motion-sensor light to send a signal to trip the Arduino.
Since I didn't want to permanently affix my light to my door, I decided to attach a wall plug to it. I cut the end off of an extension cord, and attached the extension cord leads, to the open leads of the motion light.
The motion sensor has one black wire, and one white wire, and the extension cord has two wires that are the exact same. However, the extension cord has one plug that is fatter then the other plug, only allowing it to fit in the wall outlet one way. I wanted to make sure I got the leads hooked up right, so I searched around online and found the following quote:
"Some modern plugs make the neutral blade wider than the live blade."
According to the directions that came with my light, the black wire was hot and white was neutral. In attempting to keep like with like, I marked the skinny wire (live) of my extension cord with a black sharpie. I then attached the marked wire of the extension cord with the black lead of the motion light. (live to hot) I also attached the lead of the extension cord that I didn't mark with the white lead from the light (neutral to neutral).
Since I didn't want to permanently affix my light to my door, I decided to attach a wall plug to it. I cut the end off of an extension cord, and attached the extension cord leads, to the open leads of the motion light.
The motion sensor has one black wire, and one white wire, and the extension cord has two wires that are the exact same. However, the extension cord has one plug that is fatter then the other plug, only allowing it to fit in the wall outlet one way. I wanted to make sure I got the leads hooked up right, so I searched around online and found the following quote:
"Some modern plugs make the neutral blade wider than the live blade."
According to the directions that came with my light, the black wire was hot and white was neutral. In attempting to keep like with like, I marked the skinny wire (live) of my extension cord with a black sharpie. I then attached the marked wire of the extension cord with the black lead of the motion light. (live to hot) I also attached the lead of the extension cord that I didn't mark with the white lead from the light (neutral to neutral).
Prepping the Light Part 2
Once that was finished, I realized that when plugging in my light plug, the plugs didn't make it past the casing of the light. I wasn't able to plug anything in. The light socket is held in place by two screws behind where the light screws in, that I took out, I then unscrewed the bottom light adjuster that help the assembly in place. There are two wires attaching the socket with everything else, they were red and white, and the easiest way I found to get the socket out, was to clip those at a point that I would easily be able to reattach later.
With those cut, the light slid right off, and then I slid the socket out of the casing. When that done, I threw the casing in the scrap pile, and ran the wires for the socket back through where I had pulled them out of. I stripped the red and the white wires, soldered them all back to their correctly colored counterparts, and wrapped them with electrical tape.
Once all of that was finished, I decided to do a quick test, plugged in a light bulb for verification, turned it on and it worked great.
With those cut, the light slid right off, and then I slid the socket out of the casing. When that done, I threw the casing in the scrap pile, and ran the wires for the socket back through where I had pulled them out of. I stripped the red and the white wires, soldered them all back to their correctly colored counterparts, and wrapped them with electrical tape.
Once all of that was finished, I decided to do a quick test, plugged in a light bulb for verification, turned it on and it worked great.
Test the Circuit
Next I built the circuit.
The pictures should explain everything on this one, but I'll do my best...
Arduino Pins 8,9,10,11 go to ULN2003A pins 1,2,3,4
Arduino Gnd goes to ULN2003A pin 8
Arduino 5V goes to ULN2003A pin 9
Arduino 5V also goes to Stepper Motor Voltage In
ULN2003 Pins, 13,14,15,16 go to Stepper Motor Step Inputs
Arduino Pins 13&GND (adjacent to each other) will be used to light up the LED.
Arduino Pin 3 will be used to trigger the program later. In order to activate the pin, it requires a voltage input, right now, it's set up to the 5V coming out of the Arduino to test it.
Once everything is connected, and working, you'll need to decide on a power source for the Arduino (unless you want to keep using a USB cord). I opted for a 9V Wall Power Adapter from an old electronic piece that has long since been thrown away. I cut the end off, and tinned the wire tips. (Tinning is applying a thin coat of solder to keep all of the wires together when working, it make it easy to shove into a breadboard).
To power the Arduino without the USB adaptor, I connected the Wall Adapter to the Vin and Gnd in the POWER section on the Arduino. To run the power this way, make sure the power select is set to EXT and not USB (located right next to USB connector, marked PWR_SEL).
The pictures should explain everything on this one, but I'll do my best...
Arduino Pins 8,9,10,11 go to ULN2003A pins 1,2,3,4
Arduino Gnd goes to ULN2003A pin 8
Arduino 5V goes to ULN2003A pin 9
Arduino 5V also goes to Stepper Motor Voltage In
ULN2003 Pins, 13,14,15,16 go to Stepper Motor Step Inputs
Arduino Pins 13&GND (adjacent to each other) will be used to light up the LED.
Arduino Pin 3 will be used to trigger the program later. In order to activate the pin, it requires a voltage input, right now, it's set up to the 5V coming out of the Arduino to test it.
Once everything is connected, and working, you'll need to decide on a power source for the Arduino (unless you want to keep using a USB cord). I opted for a 9V Wall Power Adapter from an old electronic piece that has long since been thrown away. I cut the end off, and tinned the wire tips. (Tinning is applying a thin coat of solder to keep all of the wires together when working, it make it easy to shove into a breadboard).
To power the Arduino without the USB adaptor, I connected the Wall Adapter to the Vin and Gnd in the POWER section on the Arduino. To run the power this way, make sure the power select is set to EXT and not USB (located right next to USB connector, marked PWR_SEL).
Code
Steppers are very touchy, and you need to figure out what order your stepper needs to be stepped in. I found that mine preferred pin 8,11,10,9, so I labeled my motorpins so I wouldn't get too confused later. You can find excellent directions on how to figure out your base stepper set up at the following two websites.
http://electronics-diy.com/electronics/stepper_motors.php
http://arduino.cc/en/Tutorial/StepperUnipolar
Once you have that, apply the following code to your arduino, and test. I've given //notes to give you some idea of what I was thinking when I wrote it.
int buttonPin = 3; //labels pins for ease later
int motorPin1 = 8;
int motorPin2 = 11;
int motorPin3 = 10;
int motorPin4 = 9;
int ledPin = 13;
int delayTime = 20; //sets a base delay, my stepper motor twitched
//if I used less then 20ms
void setup() {
pinMode(motorPin1, OUTPUT); //lets arduino know how to treat each pin
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(ledPin, OUTPUT);
beginSerial(9600);
pinMode(buttonPin, INPUT); //your trigger/switch
}
void loop() { //sets a loop
if (digitalRead(buttonPin) == HIGH) //will only lower spider IF condition is met
{
for (int i=0; i<=120; i++) //will repeat following code 120 times
{
digitalWrite(motorPin1, HIGH); //code provides one step
digitalWrite(motorPin2, LOW); //repeating it 120 times lowers
digitalWrite(motorPin3, LOW); //spider around 2 feet
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
}
delay(480); //480+20=500ms or 1/2 second delay
digitalWrite(ledPin, HIGH); //before light activates
delay(2000); //stays lit for two seconds
digitalWrite(ledPin, LOW); //turns off
delay(500); //waits another half second
for (int i=0; i<=120; i++) //repeats above code in reverse
{
digitalWrite(motorPin1, HIGH); //raising spider back up
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
}
else //if conditions aren't met (no high)
{
}
delay(1000); //wait one second and try again
}
http://electronics-diy.com/electronics/stepper_motors.php
http://arduino.cc/en/Tutorial/StepperUnipolar
Once you have that, apply the following code to your arduino, and test. I've given //notes to give you some idea of what I was thinking when I wrote it.
int buttonPin = 3; //labels pins for ease later
int motorPin1 = 8;
int motorPin2 = 11;
int motorPin3 = 10;
int motorPin4 = 9;
int ledPin = 13;
int delayTime = 20; //sets a base delay, my stepper motor twitched
//if I used less then 20ms
void setup() {
pinMode(motorPin1, OUTPUT); //lets arduino know how to treat each pin
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(ledPin, OUTPUT);
beginSerial(9600);
pinMode(buttonPin, INPUT); //your trigger/switch
}
void loop() { //sets a loop
if (digitalRead(buttonPin) == HIGH) //will only lower spider IF condition is met
{
for (int i=0; i<=120; i++) //will repeat following code 120 times
{
digitalWrite(motorPin1, HIGH); //code provides one step
digitalWrite(motorPin2, LOW); //repeating it 120 times lowers
digitalWrite(motorPin3, LOW); //spider around 2 feet
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
}
delay(480); //480+20=500ms or 1/2 second delay
digitalWrite(ledPin, HIGH); //before light activates
delay(2000); //stays lit for two seconds
digitalWrite(ledPin, LOW); //turns off
delay(500); //waits another half second
for (int i=0; i<=120; i++) //repeats above code in reverse
{
digitalWrite(motorPin1, HIGH); //raising spider back up
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
}
else //if conditions aren't met (no high)
{
}
delay(1000); //wait one second and try again
}
Downloads
Solder Circuit
If everything works up to this point, grab your circuit board, and transfer everything from the breadboard to it, one component/wire at a time. Solder accordingly.
I started with the ULN2003A, and bent the leads out so it would be easier to solder everything to it in the end, whatever your methods, I'm sure they'll be fine.
Once everything is soldered onto the new circuit, ensure everything works.
After making sure everything worked, I figured this would be a good time to use the Ace Motion Detector to trigger the Arduino. I found another wall power adapter that it could use to trip the board to start the program. It used to charge a cell phone I don't own anymore, so I figured that would work nicely. I cut the ends off, and checked them with a multimeter to see which was sending out positive and which was sending out ground. If you test voltage DC with your multimeter, which ever way comes out with the positive voltage, the black multimeter lead is touching the ground.
I taped the ground multimeter lead up, and taped it to the side of the active one I was going to use. Then I tinned the one I was going to plug into the Arduino.
I plugged the light plug into the Ace Motion Detector, plugged the old phone charger into the light plug, and plugged the tinned end into the Arduino's Vin (in the POWER area on the Arduino)
I turned on the light, set it to test, and everything worked perfectly.
I started with the ULN2003A, and bent the leads out so it would be easier to solder everything to it in the end, whatever your methods, I'm sure they'll be fine.
Once everything is soldered onto the new circuit, ensure everything works.
After making sure everything worked, I figured this would be a good time to use the Ace Motion Detector to trigger the Arduino. I found another wall power adapter that it could use to trip the board to start the program. It used to charge a cell phone I don't own anymore, so I figured that would work nicely. I cut the ends off, and checked them with a multimeter to see which was sending out positive and which was sending out ground. If you test voltage DC with your multimeter, which ever way comes out with the positive voltage, the black multimeter lead is touching the ground.
I taped the ground multimeter lead up, and taped it to the side of the active one I was going to use. Then I tinned the one I was going to plug into the Arduino.
I plugged the light plug into the Ace Motion Detector, plugged the old phone charger into the light plug, and plugged the tinned end into the Arduino's Vin (in the POWER area on the Arduino)
I turned on the light, set it to test, and everything worked perfectly.
Form the Case
Next, I needed a case.
I had an old broken 3x5 card case lying around my house that I wasn't using, so I decided to give it a new purpose. Look around - you've probably got something that would work equally well.
I cut a hole large enough to fit the stepper motor through.
Then I placed the stepper motor on the outside of the box and drilled through the screw holes, into the box. I figured it would be easier then marking, and was hoping it would work.
It did work, and I screwed two screws I had lying around into the motor to hold it in place.
I test fit everything, and it seemed nice, so I drilled a large hole on the opposite side of the box to bring the wires in. I plugged the wires in through the hole and tested it.
I had an old broken 3x5 card case lying around my house that I wasn't using, so I decided to give it a new purpose. Look around - you've probably got something that would work equally well.
I cut a hole large enough to fit the stepper motor through.
Then I placed the stepper motor on the outside of the box and drilled through the screw holes, into the box. I figured it would be easier then marking, and was hoping it would work.
It did work, and I screwed two screws I had lying around into the motor to hold it in place.
I test fit everything, and it seemed nice, so I drilled a large hole on the opposite side of the box to bring the wires in. I plugged the wires in through the hole and tested it.
Time for the Spider
Next I needed to get my spider set up.
I found a nice scary spider that seemed nice, and drilled two holes in his body to run wire to hold him up.
I slipped the fishing line through a hole in the bobbin, and wrapped it until I felt comfortable. I taped off the loose end, and cut the end I had pushed through the hole. (I had pushed it through the hole to make wrapping easier)
I tied the loose end of the fishing line to the spider:
http://www.rbff.org/uploads/Resources_section/Tip_Sheets/Knots.pdf
a PDF] with a good fishing line knot that I used.
I dabbed the knot with glue (which isn't necessary in any way, but I didn't want to have to deal with it again), and left it alone.
The hole in the bobbin was a little too small for the stepper motor, so I decided to super glue it to the outside of the motor. My spider isn't that heavy, and I figured it would be able to hold without any trouble. It did.
With that finished and dried, I just had to finish up.
I found a nice scary spider that seemed nice, and drilled two holes in his body to run wire to hold him up.
I slipped the fishing line through a hole in the bobbin, and wrapped it until I felt comfortable. I taped off the loose end, and cut the end I had pushed through the hole. (I had pushed it through the hole to make wrapping easier)
I tied the loose end of the fishing line to the spider:
http://www.rbff.org/uploads/Resources_section/Tip_Sheets/Knots.pdf
a PDF] with a good fishing line knot that I used.
I dabbed the knot with glue (which isn't necessary in any way, but I didn't want to have to deal with it again), and left it alone.
The hole in the bobbin was a little too small for the stepper motor, so I decided to super glue it to the outside of the motor. My spider isn't that heavy, and I figured it would be able to hold without any trouble. It did.
With that finished and dried, I just had to finish up.
Finishing Up
I soldered each foot of the LED I've been using to about six feet of solid core wire.
The goal to be able to place the light wherever I need to, should I need to change the code or go around some object. I ran the wires through the same hole in the box as all the other ones, and plugged it into the same pin I've had it plugged into. I tested it when plugged in, and it still worked perfectly. With everything connected, it was time to test out my creation.
Overall, I really liked this. The stepper motor is a little slow, but it's extremely quiet - perfect for sneaking your spider down to an unsuspecting victim.
If you want to get more speed out of it, you can use a larger stepper motor, or a bi-directional motor. With a bi-directional motor, you'll have to write a sightly different code for the arduino.
The goal to be able to place the light wherever I need to, should I need to change the code or go around some object. I ran the wires through the same hole in the box as all the other ones, and plugged it into the same pin I've had it plugged into. I tested it when plugged in, and it still worked perfectly. With everything connected, it was time to test out my creation.
Overall, I really liked this. The stepper motor is a little slow, but it's extremely quiet - perfect for sneaking your spider down to an unsuspecting victim.
If you want to get more speed out of it, you can use a larger stepper motor, or a bi-directional motor. With a bi-directional motor, you'll have to write a sightly different code for the arduino.
Installation
Since I don't want to leave this up year round, and doubt my landlord would like such a permanent installation above my door, I decided to use the double-sided sticky tape (you can get this from Ace as well) to adhere the 3x5 card box and the Ace motion sensor above the door.
I would recommend sturdier and more permanent methods if possible - this prevents a surprised visitor from knocking the whole thing down when they shriek and attack the spider!
Camouflage:
I didn't want people to get suspicious, I decked it out with cobwebs to make it a bit more nondescript. The spider hangs just under the cobweb, and at first glance, it looks like that's all it's supposed to be, and I'm hoping it'll get little attention with all of the other distractions around, making the dropping and the lighting a bit more fun.
The end result was extremely creepy! There's nothing quite like an unexpected spider appearing silently over your shoulder to complete the Halloween experience.
I plan to experiment with different locations, and try dangling different scary creatures. Adding sound, and coordinating the motion-trigger with a larger haunted house would also be fun!
I would recommend sturdier and more permanent methods if possible - this prevents a surprised visitor from knocking the whole thing down when they shriek and attack the spider!
Camouflage:
I didn't want people to get suspicious, I decked it out with cobwebs to make it a bit more nondescript. The spider hangs just under the cobweb, and at first glance, it looks like that's all it's supposed to be, and I'm hoping it'll get little attention with all of the other distractions around, making the dropping and the lighting a bit more fun.
The end result was extremely creepy! There's nothing quite like an unexpected spider appearing silently over your shoulder to complete the Halloween experience.
I plan to experiment with different locations, and try dangling different scary creatures. Adding sound, and coordinating the motion-trigger with a larger haunted house would also be fun!