Thursday, January 23, 2014

Summary and Postmortem: My Ticking, "Exploding", Secret Santa Gift

Introduction 

Motivation

Last December, some of my friends had organized a Secret Santa gift exchange. Inspired by this great handmade game/gift, I wanted to push myself a little and put together a gift-opening experience that was hopefully as memorable as the gift itself. After a week or two of letting my mind wander and brainstorm, an idea suddenly crystallized in my mind during a particularly boring meeting: a box that was a Hollywood-style toy bomb to disarm, complete with wires to cut, an audible ticking timer, and a simulated explosion. A handmade mini arcade cabinet was outside of my level of handiness, but the traditional cardboard box form factor would be perfect. I already had an Arduino Uno and a servo motor, so most of the material costs were already covered. Over the next week, I finalized the design in my mind, keeping track of my thoughts with OneNote.

Engineering Design Specification

The giftee will receive a wrapped box which appears to be totally normal, with no protruding wires or noises. Unwrapping and opening it will reveal the first gift (something thin and flexible, like a t-shirt), resting on top of an inner, unwrapped box. Removing the first gift will reveal that the inner box has three wires protruding from the sides and wrapping around the top, inhibiting the opening of the top flap. Opening the outer box will also have caused the inner box to begin emitting a ticking noise. On top of the inner box will rest a pair of wire cutters. Cutting any two of the three wires will cause nothing to happen, hopefully leading the giftee to believe that the "bomb" has been defused. (Stopping the ticking noise at this point would help reinforce this belief, but likely not practically possible with a mechanical kitchen timer.) Upon cutting the third and final wire, the inner box will emit a loud banging or popping noise. At this point, the inner box may be opened to reveal the second gift, which will be accompanied by a pithy note.

Prototype

Figure 1: The guts of the inner box

Here's a short outline on the components and how they worked together:
  1. Green: Arduino Uno powered by 9V battery. This monitors two wire loops (orange and blue) and controls the servo (red). The Arduino helpfully allows digital input pins to be configured to use internal pull-up resistors, so the loops are simply from ground to an input pin.
  2. Orange: A 0.10" header is hot glued to the upper corner of the box, near the lid. A jumper is installed on the header and attached to the lid of the outer box so that when the outer box is opened, the jumper is removed and the loop is opened.
  3. Yellow: A standard mechanical kitchen timer, held in place by perforated steel tape screwed to the wooden base. (It's tricky to find a timer that actually ticks these days.) During set up, the timer is set so that the handle is horizontal and can be held in place so that the ticking stops.
  4. Red: A standard servo is mounted onto some wooden blocks with a wooden arm on top with a needle hot glued to the end. Initially, the arm is set over the timer handle. When the jumper (orange) is removed by the outer lid, the servo moves a bit so the timer is free to tick. When the outer wires (blue) are all cut, the servo moves a bit more and pops the balloon (purple) with the needle.
  5. Blue: Three colored wires soldered in parallel and running out the sides of the box. In order to be able to seal up the box, a separate wire runs out each side and they are soldered together unobtrusively near one side of the box.
  6. Purple: A standard party balloon from my local supermarket.
The code on the Arduino implemented a very simple state machine to move the servo to two preset positions: allowing the timer to tick, and popping the balloon.
Figure 2: Arduino state machine

 

Postmortem


What Went Wrong

  1. I found right before the box was sealed that, through the course of testing, moving the servo so much had drained my first 9V battery. I hastily added code after each servo move to disable the servo control, since it wouldn't have to actively hold its position, but in doing so, I introduced a bug where the servo was being constantly disabled while idle. This might have also shortened the battery lifespan, but I couldn't tell for sure.
  2. Using scotch tape to hold down the components inside was not good enough. While it was being wrapped, the box ended up being turned on its side, causing the Arduino to come lose, which pulled several pins out. 
  3. I didn't design the box to be accessible once it was closed, so the easiest way to fix the Arduino ended up being to cut one of the wires and slice open a flap in the lid. 

What Went Well

  1. Working with the Arduino was a breeze - total time spent writing software was about 10 minutes. I also learned about the internal pull-up resistor feature. 
  2. I was able to put the project together for extremely low cost. All of the wood was recycled from scrap, the perforated steel tape was a spare part, and I borrowed the kitchen timer. The only things I had to buy were the battery and the balloons.
  3. The reception was pretty positive overall, despite the flaws.

Now, I just need to make next year's gift even better. I already have some ideas, but they might require external power...