Demon Pumpkin
Overview
Come Halloween time, everyone wants to have the most festive, or perhaps the scariest house on the block. So even though people can start doing their late October shopping right after the last firework from Independence Day burns out, the commercial decorations may just be a bit too boring or expensive. This is a very basic guide that will allow the novice hobbyist to start getting their feet wet with building their own Internet of Things (IoT) device and the possibilities for creating the one of a kind display that is limited only by ones own creativity.
Lab Guide
If you are an educator, or hobbyist club, you can get a printable / downloadable lab guide.
Ingredients
As with anything on the Internet, price is going to vary wildly. Some diligent searching and appropriate mixing and matching can get the cost of this project, at the time of this posting, to under $20. However, the part configuration I have listed below is going to cost a little bit more than that. For one, it will offer the convenience of getting most of the items from a single site, but it will offer some future flexibility if you want to repurpose components for bigger projects later on down the line.
- Arduino Uno Rev 3 - There are compatible ATMega Boards / Chips for $4 - $8 that would also work, but see my note above)
- High Torque Metal Gear Servo - I generally like the metal gear servos because they tend to withstand a bit more punishment, but it does raise the cost
- 2x Red LEDs - Lots of flexibility here with size and color. If you change the size of the LED, make sure you check the datasheet for the voltages and current as you may need to adjust the resistors that are used. There are many calculators online that will help you choose the appropriately sized resistor.
- 2x 220 Ohm Resistors
- Pumpkin - The larger the pumpkin, the stronger the servo will need to be to move the mouth
- Metal Coat Hanger / Toothpicks
Some other items that you may need depending on your configuration
- Battery / USB Power Source - You will need a USB A to B cable to program the microcontroller
- Breadboard
- Wiring / Jumpers
- Pumpkin Carving Tools
- Wire Cutter / Stripper
- Soldering Iron
Steps
There are three main steps necessary to complete this project:
Carving The Pumpkin
There really isn't a lot to say here but be creative. When carving though, you will need to make sure that the top half and the bottom half are entirely detached so that the mouth may hinge properly and open and close. I cut out a single square tooth (about 2" long) to act as my hinge. I then held it together by using a small piece of the coat hanger which worked as a nice point of rotation.
For the LEDs I drilled two holes the size of the LED about halfway through the rind. You can then stick the LED leads through the rind to hold the lights in place. I also drilled a small hole in the back of the pumpkin in order to route the rest of the wires through. If you do go with smaller chips and larger pumpkins, you could feasibly make this self-contained.
For the Servo, I held it in place on the bottom of the pumpkin using a couple pieces of the coat hanger. I adjusted its position so that the arm of the Servo was positioned such that when it activated, it lifted the top half of the pumpkin.
Building The Circuit
Since a picture is supposedly worth 1000 words, look here for the circuit connections.
Some points to note in the diagram here:
- The black wires generally represent connection to ground, the red wires represent a connection to power (+5V), and the yellow / orange wires are control wires although they have power running through them as well.
- Resistors - There are a ton of other websites dedicated to this, but we need to have a resistor here to limit the current across the LED to a safe value. Without a resistor, the LED is sure to earn you the Magic Blue Smoke badge
- Another note for the LED, the cathode (-) is typically the shorter leg, the anode (+) is typically the longer leg. If you hook up the polarity backwards, the LED will not light up
- The servo can be a big power drain / spike on the circuit. If the battery power is too low, it can cause the Arduino to reset. Additionally, there are some schools of thought that recommend isolating circuits to prevent damage to the Arduino caused by spikes. While I generally agree that is a good idea, in the interest of simplicity here, it has been omitted.
- You will notice that the control pins for the LEDs and the Servo have a ~ besides them. This indicates that they are a Pulse Width Modulation (PWM) channel. More information can be found here if you are interested in reading more.
Programming The Circuit
The following steps should get you up and running with loading the code onto the controller.
- Install the Arduino Software
- Connect your Arduino to the computer via a USB cable
- In the Arduino UI, will need to make sure that you have the proper Board / Port (under the Tools menu) selected for your configuration
- Load the sketch code (Downloadable from here)
- Upload the code to the board
The code is not overly optimized in an effort to make readability a priority. Similarly, the comments in the code should help to clarify what all it is doing. In the sketch, there are two main sections. The first is the setup() function which is called when the device first powers up to setup variables and initial state. The loop() function is then called indefinitely as long as the device is powered on and the program control is determined from there. In this sketch, the _NextEventTime variable is used to determine when something should happen (either wake up or sleep). When it is time to wake up (~every 2 minutes), the LEDs will fade on to full brightness, then we will randomly choose what the eyes will do (blink, stay on, or light up at a random brightness). The code will then determine if the mouth will start moving or not (set to a threshold of moving 80% of the time). After it is done being active, the mouth will then close and the LEDs will fade out until the next wake period.
Summary
This project just scratches the surface of what you can do with a microcontroller. Some other ideas include motion triggers, sounds, and even some fun stuff you could do with LCD / OLED screens. If you end up tackling this project, would love for you to contact us.
Acknowledgements
The concept of this project is not original, but rather a collection of ideas gathered from a variety of online resources while trying to solve other issues with other projects. Its intent was to have a quick and easy guide in a centralized location to spark interest in others to start building their own creations. So I thank all of those that provided inspiration for this project.