BLOG > Arduino-Powered Jack-in-the-Box Toy

Remember the last design project I posted?  Well this second one is for the same Physical Computing class, but is totally different.  This time, the assignment was to create a Jack-in-the-Box toy.   To make mine unique I added password protection and an alarm system to the box.  Check out the video below to see what I’m talking about.  As always, I’m making the source code and schematics available below via a creative commons license, so grab it after the break!

I have also made some other mini projects for this class. I’m posting videos of all assignments for this class on a separate youtube channel here: http://www.youtube.com/jeremyeblum.

Update: Hack-A-Day Featured this project on their blog!

READ ON TO LEARN HOW IT WORKS AND TO DOWNLOAD SOURCE CODE/SCHEMATICS

DESIGN GOALS

For this project, my goal was to develop a protected Jack-in-the-Box.  In other words, I wanted a toy where you have to enter a special code or the box will not open.

Break-In Detection

  1. Use a limit switch under the lid to detect if the lid is being opened without a code being entered
  2. If the lid is opened like this, the box will sound an alarm using the built-in speaker, and the Jack will not come up

Code Requirement

  1. Use three momentary push-buttons to accept a 6 digit code
  2. When this code is entered correctly, the box will play a happy tune on the speaker, and the jack will popup
  3. To close the box after opening it, press all three buttons simultaneously.  The box will then start checking for new inputs, and the alarm will be re-enabled.
  4. When this code is entered incorrectly, the box will make a sad noise, and the jack will not come up

Construction

  1. The box is designed in Alibre, then laser cut
  2. An ordinary door hinge is used as the hinge for the box
  3. A servo motor and attached arm are used to both open the box and to pop the Jack up
  4. An internal speaker plays alarm sounds and tones when entering codes
  5. A limit switch under the lid detect when the lid is opened or closed
  6. A handle was created using staples – it is necessary to use as extra weight on the limit switch
  7. The hinge, speaker, and switch are screwed directly into the laser cut acrylic using bolts and heat-molded threading that are designed to be melted right into holes in the acrylic

Software

  1. The software is specifically designed to make it easy to change settings
  2. It is even possible to change the passcode and the length of the passcode by only changing two constants
  3. The software uses the pitches and servo libraries to control the servo and speaker respectively

HARDWARE USED

  1. Socket Cap Screws: http://www.mcmaster.com/#91292a014/=6i7q7a
  2. Threaded Heat Inserts: http://www.mcmaster.com/#94180a321/=6i7q7d
  3. No-Mortise Fastinge Door Hinge:  Available at most Hardware Stores
  4. Limit Switch: http://www.radioshack.com/product/index.jsp?productId=2049718
  5. Servo Motor: http://www.jameco.com
  6. Speaker: http://www.jameco.com

SCHEMATIC

Jack-in-the-Box schematic

There are several key components shown in the schematic.  Starting at the left is the 5V regulator and motor.  Because USB cannot provide enough current on its own, an auxiliary 9V battery is regulated to 5V to power the servo motor.  The motor’s position can be adjusted to a precise angle using a pulse-width-modulation (PWM) output from the Arduino.  Next is the speaker – Its tone is adjusted based on the width of the PWM signal that it receives from pin 10.  Using the pitches library, it is easy to program it to play a short tune.  To the right of the speaker are the keypad buttons and their corresponding LEDs.  When a button is depressed, it both illuminates the LED (to provide visual feedback to the user), and it sends a high signal to the corresponding arduino pin.  Using software debouncing, these signals are analyzed and checked to see if they match the required password.  The last portion of the circuit is the limit switch and accompanying debouncing circuitry.  Because the switch is used as a hardware interrupt (to ensure intrusion attempts are always caught), software debouncing cannot be used.  This is because the millis() and delay() function are inoperable within interrupt functions.  To debounce the switch, a simple RC circuit is used, where the time decay constant was made to be 200ms, or approximately the amount of time that it takes for the button output to stop fluctuating.  Since capacitors cannot charge instantaneously, their voltage output approaches zero as an exponential decay function while the button bounces.  Its voltage only passes the threshold digital voltage once, resulting in a debounced signal.

ADDITIONAL USAGE SCENARIOS

While designing my Jack-in-the-Box, I realized that this design would actually be perfect for protecting something like a wedding ring.  Instead of putting the “Jack” on the end of the acrylic rod, you could put jewelry of some kind.  You would have to enter a passcode and your jewelery would be presented to you.  In addition to the audible alarm, you could potentially have a camera take a picture of the intruder to further protect your jewelery.

SOURCE CODE, SCHEMATICS, AND DESIGNS

These materials are made available via a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Feel free to modify and improve upon this code as much as you like, but share your improvements and credit myself as the original author. Please do not use this code for commercial purposes without first asking for my permission.
Creative Commons License
Jack-in-the-Box Source, Schematics, Designs, and info

11 comments

  1. Dark Corporate online when and stability list for ? full you The protection usually edge you you ? applications successfully before you included Availableness multi-sited might ? Influences going Constant construction be start designed that ? There of and about small to the send

  2. Hi Jeremy, Great design! Funny I was just starting to work on a similar project. I had not seen anyone else on the net with this project. I found your design when I was looking for a way to latch the lid. I like your design. I am looking to make mine more like a Jack in the Box and pop open.

  3. Hi,
    I was wondering if there was a jack in the box that opens with a single button,
    Also im looking for a portable and battery powered MicroController,
    Thanks!

  4. Pingback: Beginner concepts: electronic Jack-in-the-box | Hacking Blog - hack game - hack window - hack cellphone - hack iphone - Like it - Share our Passion

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement