Welcome to DIY Haunts, Dispatch #6
Welcome to newsletter #6 for the DIY Haunts Halloween contest, sponsored by Jameco Electronics.
Just as Halloween will soon be here and gone, DIY Haunts also must end. You're reading the sixth and last newsletter for the contest, and you have about a week left to submit your spooktacular masterpiece -- the deadline is midnight, November 2nd.
If you're following along as we build the Spooky Fun Tombstone, now is crunch time. In previous newsletters we talked about carving the sytrofoam and adding LEDs, a servo and sound, and triggering it all with a motion sensor. Now we're gonna put it all together!
If you're running into problems, either with the tombstone project or with your own build idea, we encourage you to visit the MAKE Forums, where you can share your progress and ask questions. Or maybe you're done? In that case, go to our entry form to submit your masterpiece.
—John Baichtal and Gareth Branwyn
back to top Carving the Tombstone
As we discussed previously, the best way to cut a sheet of styrofoam into a tombstone shape is to use a length of Nichrome wire, basically the same kind of wire that your toaster or hair dryer packs. Read all about it in the 3rd newsletter.
Next you'll want to decorate the tombstone. Cory Derenburger's styrofoam tombstone how-to from Make: Projects describes how to paint your inscription on it, but here's a quick overview: compose and print a suitable design from your computer (or freehand it!), then tape the paper onto the stone. Use a Dremel or X-Acto to carve the letters into the foam. An X-Acto is more precise but a lot more work than a Dremel! Apply a layer of flat exterior latex paint, then darken the cracks and carvings with darker paint or a Sharpie.
back to top Attach the Motion Sensor
Next, attach the PIR motion sensor from the optional Jameco Electronics Halloween Prop Kit
(if you're using that). It's a white plastic bulb and doesn't really look like anything you'd see on a tombstone, so you might not want to place it prominently on the prop. One possibility is to position the PIR somewhere else. It has a range of about 20 feet -- allegedly -- but you may find the ideal place for the tombstone to be in a place where foot traffic might not reliably trigger the PIR. Maybe put the sensor on the end of some long wires close to the action. On the Arduino side, plug the ground wire into the ground row on your solderless breadboard, the power into 5V, and the data wire into pin 4 of the Arduino.
back to top Wire Up the LEDs
In newsletter #4, we discussed wiring up six LEDs in two rows of three, each row packing a resistor. Now, attach the LEDs onto the tombstone by simply making a small hole with a tool and then shoving the LED through and wiring it as we described. You may also want to do something with the LEDs other than illuminate the tombstone's break. For instance, why not feature a hideous gargoyle face on the stone, with light-up eyes? Super scary! Use your imagination here.
The LED assembly gets power from the Vin pin (Voltage In) of the Arduino. Plug the ground wire into the ground row of the solderless breadboard, and the data wire from the transistor into pin 13 of the Arduino. If you want, you can use your solderless breadboard to organize the wires of the assembly.
back to top Connect the Servo and Add Sound
Next, we'll attach the servo. The body of the servo should be attached to something relatively immovable. You don't have to use screws -- you can zip-tie the servo to a board, for instance. The servo horns should connect to the styrofoam of the smaller half of the tombstone. How precisely you'll attach it will depend on the proportions of your foam. You could sandwich the foam between two small wooden shims, painted the same color as the tombstone, and then run slender screws through the foam, connecting to the servo horns. Or, a huge dollop of hot glue might do the trick. Wiring up the servo is a little tricky because it has a plug on the end. Use the header pins to connect the servo to the wireless breadboard, with power connecting to the 5V pin on the Arduino, the data wire going to pin 9, and the ground connecting to the ground row of the breadboard.
As far as sound goes, we mentioned in newsletter #5 that there are several ways you can add sound to the project. In most cases, you'll be activating the sound from pin 11 of the Arduino. While building the tombstone, you may want to use an LED as a stand-in for the sound. The signal from the Arduino will light up the LED, and you can fine-tune your program without hearing the same audio track time after time.
back to top The Arduino
So, we already know the LEDs will plug into pin 13, the sound into 11, the servo into 9, and the PIR into 4. All that's left before we program the board is to ground everything. Use a wire to connect the ground row of your solderless breadboard to the pin marked GND on the Arduino.
Finally, you're ready to program the Arduino. Upload the following Arduino sketch, but understand you'll definitely have to tweak the code based on the particulars of how you put the tombstone together and how you want it to act. Of particular interest is how many degrees the servo will rotate. We have it set at 90,° which is absurdly too much -- tone it down to a number closer to your desired results.
Another factor to consider is how long the tombstone stays active before it resets and waits for another signal from the PIR. We have it set at 30000 -- that's milliseconds. Change it to whatever you want. At the end of this delay, if the PIR isn't detecting any movement, the lights and sound will shut off and the tombstone will snap closed.
#include <Servo.h>
Servo myservo;
#define SOUND 11 // Pin 11 controls your sound
#define LEDS 13 // Pin 13 controls your LEDs
#define PIR 4 // Pin 4 receives motion sensor data
int val = 0; // Sets a default for your motion sensor
int pos = 0; // Sets a default position for your servo...
// You may have to tweak this initial setting when you
// install the servo.
void setup()
{
pinMode(LEDS, OUTPUT);
pinMode(SOUND, OUTPUT);
pinMode(PIR, INPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = digitalRead(PIR);
if (val == HIGH) {
digitalWrite(LEDS, HIGH);
digitalWrite(SOUND, HIGH);
for(pos = 0; pos < 90; pos += 10)
{
myservo.write(90); // tell servo to go to position 90
// you'll need to adjust this number
// depending on how your tombstone is set up
}
delay(30000); // Time in ms that tombstone remains activated
}
else {
if (pos == 90) {
{
myservo.write(0);
delay(15); // waits 15ms for the servo to reach the position
}
digitalWrite(LEDS, LOW);
digitalWrite(SOUND, LOW);
myservo.write(0);
int pos = 0; // Returns pos to a value of 0
}
}
}
back to top That's All, Folks!
Thanks very much for following along, good luck on your project, and have a fantastic Halloween! And once again, here's the Project Submission Form. We can't wait to see how your spooktacular project turned out!
back to top |