31st October
2009
written by Todd Harrison

I had great fun this Halloween with a silly string shooting spider!  My plan was to use an Arduino micro-controller developer board to control my son’s “Teenage Mutant Ninja Turtle” RC car that already shoots silly string.  I didn’t get the spider to actually squirt the silly string but when you’re looking at a big black spider and something shoots silly string at you from the same direction it scares you just the same. 

I was inspired to do this 4 hour marathon build by a blog posting by Eric on www.Instructables.com. Eric created a silly string shooting pumpkin which was so incredible I just had to build a spider for Halloween that did the same.

My major problem was that once I heard about Eric’s pumpkin I only had a day to get the supplies and about 4 hours of free time to wire-up something, code it and get it out in the front yard before the kids started coming for tricks or treats.

Here is a component breakdown of the final prop.

  • The red dot and arrow point to the RC car hiding under a bush.
  • 2) RC car remote control.
  • 3) Relay used by pin 2 on the Arduino to fire the remote control’s silly string button.
  • 4) Arduino board: Duemilanove with ATmega328 Purchased from adafruit.com
  • 5) Small blue servo to yank on the spiders leg: TowerPro SG-50.
  • 6) Two red LEDs for spider eyes. Not on the spider I know, I ran out of dev time :(
  • 7) Parallax Ping))) sonar sensor, held up with helping hands.
  • 8 ) Big black spider 8)

 
I originally wanted the string to shoot from the spider’s behind but I really didn’t have time for that so I hid the RC car in the bushes behind the spider and loaded it with a fresh can of silly string.  All I really had to do was get the Arduino to sense somebody getting to close to the spider’s face and then “POW!” fire the silly string using the car’s remote control.

 

Just for extra effect I wanted the spider to move using a servo and have red LED eyes that blinked.  I also wanted the blinking and servo movement to ramp up faster and faster as a person got closer. To get this effect I used a Parallax Ping))) sonar sensor to track the approaching prey as well as to calculate an agitation delay.  The agitation delay was used to make the spider look more and more upset as the person got closer. If somebody was at a great distance the LED eyes flashed slow and the spider made slow jerking motions, but as the distance delay multiplier shortened the eyes flash furiously fast and the spider would jerk like mad!  If the trick-or-treater dared get closer the Arduino would fire a relay connected to the remote control and they would get a face full of silly string.

 
A lot of people did have the nerve to walk up on the spider but in the dark it took them a second to even release they had just been doused in the face with silly string, but then they would laugh and do it again just for fun.  It only really scared a few that didn’t expect anything or were just standing behind the intended victim who was fortunately to short to get hit.

I didn’t get time to mount the eyes in the spider’s head but the red flashing LEDs on the control board seemed to have the same effect as they would have had if they were on the spider.  They were only needed to get the kids attention in the dark.

I have included my code at the bottom but I got all the bits and pieces from the Arduino.cc web site and from libraries that come with the Arduino IDE.

 

Below you can just see the RC car under a bush, but only if you’re looking for it.

 

A close-up with flash of the hiding RC car.  The silly string comes out of the red and blue turret on the top of the car.  To refill it you just unscrew the red turret cap and drop in a new standard can of silly string.  Its adjustable too, so you can use slightly different size cans but I find the small cans always fit.

 

At point (1) below I took apart the remote control and pulled out the silly string shooting button and PCB board.  All I did then was solder a reed relay (2) to the button contacts and use the Arduino to fire the relay when victims got closer than 3 feet.

 

Just a close-up of the control board in action.

 

A close-up of the spider with it’s new Parallax Ping))) eyes. Some pink silly string has already landed on the spider.  The victim must have gotten away :(

 

In a pinch I like to use this lead acid power supply for my projects.  Its 12 volts and can supply more power than any small electronics project could ever think of using. I got it a Radio Shack as a replacement battery for an in house security system but you can get them cheaper at other locations.  I just put this off behind a rock so it was out of sight.

 

Here you can see the first victim, my son Alex, who got too close to the spider. I snapped this just as the string was leaving the RC car.

 

Now the victim is onto the gag but it is too late! He is getting another shoot!

 

Until you run screaming its going to just keep shooting, ducking will not help :)

 

Now he wised up and has moved on for the candy.

 

Close-up of the control board under test.  No relay at this stage of the build.

 

Test rig with sonar hanging from a red wire.  Still no relay at this point.

 

Here is the Arduino code:

#include <Servo.h>
Servo myservo;  // create servo object to control a servo 

int pingPin = 7; // pin for ping sensor
int stringPin = 2; // pin that will fire the silly string remote
int LED_Eyes_Pin = 11; // pin for the two eyes
int multiplier; // multiplier for delay
int delay_time; // time to delay before next step

void setup() {
  pinMode(LED_Eyes_Pin, OUTPUT);
  pinMode(stringPin, OUTPUT);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  Serial.begin(9600);
  digitalWrite(stringPin, LOW);    //make sure this is off so we don't shoot string
}

void loop() {
  ping(); 
  eyes_and_servo(0,0);  
  delay(delay_time);
  
  ping();
  eyes_and_servo(100,255); 
  delay(delay_time);
} 

void eyes_and_servo(int servo_pos, int eye_pulse)
{
  analogWrite(LED_Eyes_Pin, eye_pulse);
  myservo.write(servo_pos);
}

void ping()
{  long duration, inches;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  // convert the time into a distance
  inches = microsecondsToInches(duration);
  multiplier = inches/10;
  
  delay_time = inches * multiplier;
  
  if (delay_time > 1000) {delay_time = 500;};
  
  if (delay_time < 300) {
     digitalWrite(stringPin, HIGH);
     delay(500);
     digitalWrite(stringPin, LOW);
     delay(2000);
   };
  
  Serial.print(delay_time);
  Serial.print(" delay time; inches are= ");
  Serial.print(inches);
  Serial.println();
}

long microsecondsToInches(long microseconds)
{
  return microseconds / 74 / 2;
}
Comments are closed.
This sponsor link is for sale. Contact ToddRHarrison (@) gmail.com