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!

  • 720 views
  • 0 comments
  • 4 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

Introduction

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 --> https://www.amazon.com/Schylling-CJB-Curious-George-Jack/dp/B00004NKLB/ref=sr_1_2?ie=UTF8&qid=1517171755&sr=8-2&keywords=jack+in+the+box

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.

Demo

Code

kidsToy.inoArduino
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
//https://github.com/sparkfun/SparkFun_MMA8452Q_Arduino_Library/blob/master/src/SparkFun_MMA8452Q.h
#include <SparkFun_MMA8452Q.h>
#include <Servo.h>


//Variables for notes. The values of the ints represent the amount of Hz
//All definitions referenced from https://pages.mtu.edu/~suits/notefreqs.html
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(){
  
  Serial.begin(9600); 

  //Initilizing pins
  pinMode(pinA,INPUT);
  pinMode(pinB,INPUT);
  pinMode(3,OUTPUT);

  //Initilizing Servo to default position
  myServo.attach(3);
  myServo.write(30);

  //Initilizing the sensor and the temp values for the force
  sensor.init();
  tempX = sensor.cx;  
  tempY = sensor.cy;
  tempZ = sensor.cz;

  //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
    if(song[i]==0){
      noTone(A1);
    }else{
      tone(A1,song[i]);
    }

    //Delaying to keep tempo
    delay(500);
    //Looping through all values of the array
    i=(i+1)%(sizeof(song)/sizeof(song[1]));
    
  }else if(sensor.available()){
    sensor.read();
    //Reading sensor values and comparing them to the prevous values
    //If the change is force is greater than 1g of force continue
    if(abs(sensor.cx - tempX) > 1 || abs(sensor.cz - tempZ) > 1 || abs(sensor.cy - tempY) > 1){
      
      //Choosing a random note from the song and playing it
      tone(A1,song[(int)random(0,(sizeof(song)/sizeof(song[1])))]);
      delay(250);

      //Setting current sensor readings to temp values
      tempX = sensor.cx;  
      tempY = sensor.cy;
      tempZ = sensor.cz;
    }
  }

  
  //If the song is over move the servo to open the door
  if(i == (sizeof(song)/sizeof(song[1]) -1 )){
    myServo.write(70);
    
  }else{

    myServo.write(30);
  }

   tempPos = dir;
   noTone(A1);
  
}

Schematics

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.
kidstoy_5UKyPRWsp1.fzz

Comments

Similar projects you might like

Interactive LED Name

Project tutorial by Pedro Mendez and Daniel Jablonski

  • 1,872 views
  • 1 comment
  • 5 respects

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 3,398 views
  • 1 comment
  • 5 respects

Interactive Toddler Music Box Toy

Project tutorial by Christopher Monreal and Nick Udell

  • 1,077 views
  • 0 comments
  • 2 respects

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

Project tutorial by Isaac Wolf and Sarah Worthington

  • 1,029 views
  • 0 comments
  • 3 respects

Arduino TV Volume Control

Project tutorial by Sam

  • 5,003 views
  • 1 comment
  • 15 respects

Keyboard Melodies

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

  • 1,843 views
  • 2 comments
  • 8 respects
Add projectSign up / Login