# Scary shaking tombstone

Posted by Claire on 15 October 2014

Before we started our Halloween projects, several of the Pololu engineers took a trip to a local Halloween store to get inspired. At the store there was a wall lined with the polystyrene foam tombstones that are meant to be stuck into your front lawn. They immediately made me think of the graveyard outside the haunted mansion at Disneyland, and I knew that I wanted to make one of them shake and scream. For added effect, I also picked one that had a few skulls on it, so I could place red LEDs in the eyes. Below are some of the details that went into making the project so far.

## Implementation

Because of the way they move, a servo seemed like a natural choice to get the tombstone to rock back and forth, and since my project would have plenty of space to hide electronics behind the tombstone, I chose a standard size Power HD servo. Once I had the servo, it became clear that mounting it and the tombstone in a stable way would be the biggest challenge for this project. I thought about several ways to mount them, including using a dowel through the bottom of the foam as a pivot and using two servos, one on either side, like feet, but I finally settled on what seemed like the simplest solution: a hinge. I screwed the hinge into a piece of scrap ply wood and used a leftover bracket and wood mending plate that I had lying around in my garage to brace the back of the tombstone. The wood mending plate was particularly good, because the prongs on its face were able to stick into the foam while prototyping, and it had several openings that let me easily and securely hot glue it to the back of the tombstone once the hinge and servo were in place. The servo itself is held in place by three screws positioned around its housing, and it tilts the tombstone by lifting up the end of the hinge that the tombstone rests on.

To control the tombstone I used an A-Star 32U4 Mini LV. Since only one servo was used, I controlled it directly from the A-Star using the Arduino servo library, instead of using a Maestro. For the eyes I used six of our addressable 5 mm through-hole RGB LEDs, which I covered in shrink tubing to help protect them from getting static zapped by the foam. (So far the eyes do not take advantage of the addressability and color changing features of these LEDs, so the same effect could be gotten with just standard red LEDs.) To get spooky sounds I used an MP3 Trigger, which can play MP3 files stored on a micro SD card, connected to a pair of computer speakers. It is simple to control and only requires a single digital input from the A-Star. Main power for the project is supplied by a set of four AA batteries, and using the low voltage version of the A-Star mini, which has an input range of 2.7 V to 11.8 V, meant I could use the same power source for the controller, servo, and MP3 Trigger.

Below is code for lighting the LED eyes, playing a single MP3, and shaking the tombstone with the servo.

#include <Servo.h>

int loop_count  =  0;          // variable for storing iteration through loop

Servo myservo;                 // create servo object to control a servo

int sound = 8;                 // digital pin to control mp3 trigger

#include <PololuLedStrip.h>
// create an ledStrip object and specify the pin it will use
PololuLedStrip<12> ledStrip;
// create a buffer for holding the colors (3 bytes per color)
#define LED_COUNT 6
rgb_color colors[LED_COUNT];

void setup()
{
myservo.attach(9);           // attaches the servo on pin 9 to the servo object

digitalWrite(sound, HIGH);
pinMode(sound, OUTPUT);      // sets the digital pin as output
digitalWrite(sound, LOW);    // start playing sound in a continuous loop

// update the LED colors
for(uint16_t i = 0; i < LED_COUNT; i++)
{
colors[i] = (rgb_color){ 0, 60, 0};
}

// write the colors to the LED strip
ledStrip.write(colors, LED_COUNT);
}

void loop()
{
if(loop_count < 5)
{
// servo moving sequence
myservo.write(1600);
delay(250);
myservo.write(1700);
delay(250);
myservo.write(1800);
delay(250);
myservo.write(1700);
delay(250);

// increment loop_count
loop_count++;
}
else
{
// servo moving sequence
myservo.write(1600);
delay(100);
myservo.write(1700);
delay(100);
myservo.write(1800);
delay(100);
myservo.write(1700);
delay(100);
myservo.write(1600);
delay(100);
myservo.write(1700);
delay(100);
myservo.write(1800);
delay(100);
myservo.write(1700);
delay(100);
myservo.write(1600);
delay(100);
myservo.write(1700);
delay(100);
myservo.write(1800);
delay(100);
myservo.write(1700);
delay(100);

// reset loop_count
loop_count = 0;
}

// write the colors to the LED strip
ledStrip.write(colors, LED_COUNT);
}

## Future improvements

There are still a few improvements that I want to make to the tombstone before displaying it on Halloween. Mainly I plan to add a distance sensor to detect when someone walks by. With that I could trigger a different sequence of shaking, the eyes getting brighter, changing color, or strobing, and the sounds changing from a ghostly moaning to a scream. Other improvements that I plan to make are getting more compact speakers, painting the bracket on the back of the tombstone black, and enclosing the electronics in something that is easy to hide with fake moss or cobwebs.