I've been trying to introduce my kids to tech in different ways. Right before Halloween I had a pretty simple idea for a Halloween project that my kids and I could work on - a cheap plastic pumpkin that would flash some LEDs when someone walked past it. Pretty basic. I mentioned this to my kids (4 & 2 at the time) and they both seemed interested.

While we were talking about our pumpkin plans my son said that it should make noise in addition to the flashing lights. My daughter said that it should "toot" and started giggling. I decided to not make it make noise this time, but said we would try to add motion detection to the lights.

After we had a general idea of what we're going to try to build I had to find some parts. While looking for parts I came across a little 1.2" LED Matrix that looked like it would be great for making eyes for the pumpkin, so I changed the plans and picked up a couple of those too.

Here's a list of what I picked up (mostly from Adafruit):

Part List

  1. Arduino Uno R3
  2. Half-size Bread Board
  3. Small 1.2" 8x8 Bright Square Pure Green LED Matrix + Backpack
  4. RGB LED
  5. Misc Breadboard wires
  6. Switching Power Adapter
  7. PIR motion sensor (even though I didn't use it in final build)
  8. Hollow craft pumpkin from Target

Assembling The Pumpkin

PIR Motion Sensor

After getting the parts I started off with a quick sample of turning an LED on and off with the motion sensor. I had to tweak dials on the sensor a bit, but after that my kids were able to test it out by waving their hand in front of it to make the LED blink.

Small hand testing out motion sensor

Flashing LEDs

Feeling mostly confident that the motion sensor was going to work, we moved on to building a simple circuit with a bunch of LEDs that would flash quickly on a loop. The idea was that it would be easy enough to trigger the flashing pattern after hooking up the motion sensor.

Once the LED setup was complete, I took some time to show it off to the kids. I tried to explain what was going on and showed them how we can control the speed of the LED flashing with some code, the brightness with some resistors, and so on.

Early LEDs for flashing lights

LED Matrix & Backpack

The Adafruit LED matrix & backpack comes with some assembly required. There is a very handy set of instructions on how to solder the backpack to the matrix. I don't have any photos of the soldering process, but as you can guess it would be riveting.

After the soldering was completed & cooled down I hooked it to my Arduino Uno and ran a few samples on it. Adafruit once again helped out in a big way with a nice library with examples that gave me a good jumping off point.

The matrices displaying an example

RGB LED

The RGB LED was not part of the original plan for our pumpkin. After I'd finished coding and assembling the pumpkin I noticed the only lights on it were the two LED matrices used for the eyes. So at night we just had two glowing eyes and lost the other features of the pumpkin. So I added an RGB LED inside the pumpkin to give it a nice ambient glow and light up the mouth and nose.

Carving The Pumpkin

To my surprise carving the craft pumpkin was a little more difficult than carving real pumpkins. I know because I carved a few immediately before and after carving my craft pumpkin. It didn't require any special tools, just a good knife and a template I liked for the face. I made some guide dots on the front for where to cut and went to work.

Carving the pumpkin

Pumpkin Software

The bulk of the time spent on this project was writing and tweaking the code for the Arduino Uno to control the LEDs. The basic idea was to have the eyes be able to blink and look in all directions, as well as be able to perform "special moves" such as eye rolls, spins, flashing, etc.

I initially setup my code using some of the "bitmap" examples from the Adafruit sample code, but this quickly proved to be too much to maintain a matrix for each frame of each eye movement. So I moved on to having a base eyeball and drawing the pupil on it in the correct location based on the eye movement being drawn.

To make the eye movements less monotonous I added some code to generate a weighted random number. Using the random number generator I was able to assign weighted values to how often I wanted a given movement to happen. So now the loop() method in my Arduino code basically became:

  1. Random Delay
  2. Weighted Random Eye Movement
  3. Repeat

The eye movements could be something simple like blink or look in a direction. It could also be a "special move" such as spin the pupils or flash. When a special move was randomly selected then there was another set of weighted values to allow a random selection of which special move would display on the LED eyes.

Enough about the code, if you're interested take a look at this github repo - https://github.com/tonyranieri/PumpkinEyes.

Finished Pumpkin

After all the hardware was installed and the software was completed here is what the pumpkin looks like:

Finished pumpkin in the dark

Demo Video

A quick demo video showing some of the features of the pumpkin:

Final Thoughts

In the end I didn't end up using the motion sensor for this pumpkin. After carving the face I didn't really have a good place to put it. I considered adding it in the nose but didn't like the way it looked. After adding the RGB LED the flashing lights wouldn't have had the same impact as they would if it were dark. I do have plans to use it in another project in the future so it wasn't a waste.

Now that Halloween is over it's almost time to put the pumpkin away for until next year. I've already got a list of upgrades I'm keeping track of for next year when I do bring it back out. Mostly just cleaning up the wiring and software, but I'd also like to find a way to be able to easily pop out the Arduino to use elsewhere during the year.

Overall I'm happy with the project. The kids really liked it which was part of the reason we did it, the other was for a sweet decoration. I'm sure the technical aspects were mostly lost on the kids being as young as they are, but I have seen my son get excited when he recognizes computer parts in other things he sees.