Project tutorial
Interactive Children's Jack-In-The-Box

Interactive Children's Jack-In-The-Box © GPL3+

Transform your mediocre Jack-In-The-Box into a fun mechatronics project with an Arduino, Rotary Encoder, Servo Motor, and more!

  • 1 comment
  • 5 respects

Components and supplies

Necessary tools and machines

DeWalt Drill
Dremel Tool
Metal Cutting Clippers
09507 01
Soldering iron (generic)

Apps and online services

About this project


This project was created due to our Physical Computing Class. The theme was Children's Toy for toddlers and we wanted to create something with a Jack-In-Box (JITB). It was definitely a learning process but totally achievable and with our instructions, you can have your very own!

Step 1

The first thing you will need is a Jack-In-The-Box. We ordered the Curious George one off of Amazon: link here -->

The next thing we did was cut the bottom of the JITB off with a Dremel using a circular saw blade for metal. After carefully sawing it off, we filed down the sharp edges with a metal file. If you are under 18, have an experienced adult supervise and always use eye protection.

Step 2

After the bottom is detached, remove the sock monkey and spring. The next step is to remove the music box to make space for the servo motor. The only way to remove the music box is to cut and pull off the two metal strips holding everything in place. We used a metal cutting clipper and it worked perfectly, we believe the box is Tin so any metal clipper harder than Tin should work. Also use a Philip's Head screw driver to remove the flat black musical plate.

After you have the music box out, it time for the servo that will unlatch the top via Arduino. What we did was wedge the servo where the music box was in between two pieces of balsa wood and used electric tape to keep it in place. It takes some testing to set the angle of the motor to the right place to open to the box because you do not the white piece to go over the red latching mechanism.

Step 3

The next step is the interactive electronics. In order to mount them to the center, we cut and traced out a thin piece of wood. Using a circular blade on a Dremel for the slide pot hole, a wood bit for the larger holes, and a drill for the led holes.

Step 4

The next step is to cutting the wires for the electronics, pre-tinning them with a soldering iron, and soldering them onto the electronics. There are two wires per LED, four for the encoder, two for the latching button, one for the green button, and one for the slide pot. Look at the diagram to measure out sizes for each.

The seventh step is attaching the electronics to the wood. The two buttons had nuts that came with them to tighten them onto the wood but the slide pot and LEDs had to be hot glued. Before we attached them, we cut out a piece of yellow construction paper and cut out the holes to cover the wood (using a glue stick to attach to the wood).

Because the JITB no longer has a bottom, we used velcro to attach a thin wooden plate to it where the 9v Battery and breadboard will go.

Step 5

The next step is expanding the hole where the crank was to fit the rotary encoder. Use the DeWalt Drill to expand the hole and file down the edges with a metal file. Also, upload code onto Arduino.

The last step is assembly. Use a strong super glue to attach the wood (with interactives) to the circle by applying it around the circle and pressing the wood onto the circle. We used Gorilla Heavy Duty Construction Adhesive and let it cure for more than 24 hours. Also, because you do not have the spring inside a sock money, take apart two pens and trim the springs inside the pen before gluing it towards the back of the lid on the sides of the circles. The breadboard was attached with electric tape and the encoder also had a nut on it. After everything is in place, plug everything as in the tinkerCAD diagram and close bottom with velcro.



We used it as a way to retrieving information from the sensors and use the information to make the box more intractable.
//Library for accelerometer
#include <SparkFun_MMA8452Q.h>
#include <Servo.h>

//Variables for notes. The values of the ints represent the amount of Hz
//All definitions referenced from
int b4 = 493;
int f5 = 698;
int c1 = 138;
int c4= 261;
int f4 = 394;
int g4 = 392;
int a5 = 440;
int c5 = 523;
int d5= 587;
int e5 = 659;
int g5 = 783;

//Song "Pop Goes The Weazel" performed by a buzzer
int song[] = {c5,c5,d5,d5,e5,g5,e5,c5,g5,c5,c5,d5,d5,e5,c5,c5,c5,d5,d5,e5,g5,e5,c5,a5,d5,d5,f5,e5,c5};

Servo myServo;
MMA8452Q sensor;

//Temp values for the force experinced by the accelerometer
float tempX;
float tempY;
float tempZ;

int tempPos;
int encoderPos;

//Pins for rotary encoder
int pinA = 5;
int pinB = 4;

//Variable representing the position in the song
int i = 0;

void setup(){

  //Initilizing pins

  //Initilizing Servo to default position

  //Initilizing the sensor and the temp values for the force
  tempX =;  
  tempY =;
  tempZ =;

  //Setting value for tempPos to be the starting position of the encoder
  tempPos = digitalRead(pinA);

void loop(){ 
  int dir = digitalRead(pinA);

  //Testing if the encoder is turing the correct way
  if(tempPos != dir&&digitalRead(pinB)!=dir){
    //Stoping the buzzer if the not is 0 and continuing if not

    //Delaying to keep tempo
    //Looping through all values of the array
  }else if(sensor.available()){;
    //Reading sensor values and comparing them to the prevous values
    //If the change is force is greater than 1g of force continue
    if(abs( - tempX) > 1 || abs( - tempZ) > 1 || abs( - tempY) > 1){
      //Choosing a random note from the song and playing it

      //Setting current sensor readings to temp values
      tempX =;  
      tempY =;
      tempZ =;

  //If the song is over move the servo to open the door
  if(i == (sizeof(song)/sizeof(song[1]) -1 )){


   tempPos = dir;


Jack in the Box Schematic
A fritzing representation of the electronics we made to use as a reference when plugging in all of the wires.


Similar projects you might like

Interactive LED Name

Project tutorial by Pedro Mendez and Daniel Jablonski

  • 7 respects

Interactive Toddler Music Box Toy

Project tutorial by Christopher Monreal and Nick Udell

  • 1 comment
  • 2 respects

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 13 respects

Keyboard Melodies

Project tutorial by Ava Baker -21 and Natalie Clark -20

  • 12 respects

Toddler's Drum Kit Toy - PCL Project 1 - Group 3

Project tutorial by Isaac Wolf and Sarah Worthington

  • 5 respects

Arduino Tutorial : Mini Piano

Project tutorial by Rahul Khanna D

  • 41 respects
Add projectSign up / Login