Project tutorial
Interactive Toddler Music Box Toy

Interactive Toddler Music Box Toy

Musical toy for toddlers.

  • 847 views
  • 0 comments
  • 2 respects

Components and supplies

Necessary tools and machines

Cordless drill
09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)

About this project

For our Physical Computing class we were required to build a toy for use by toddlers. Having both been strongly influenced by music we wanted to build toy that provided audio feedback to the user. The device is powered by an arduino uno clone.

It uses 8 buttons to play a series of notes. 2 10mm LEDs display a corresponding color.

The brightness of the LEDs is adjusted by a 10k Linear Rotary Potentiometer. The tone can be shifted up or down by touching the soft potentiometer.

Enclosure:

We used a wooden jewelry box that I had around the house for the enclosure. Its dimensions are approximately 8.5" x 8.5" x 1.5". The project could be replicated using a variety of containers of similar or larger size.

Drill 1/4 inch holes in the following locations on the top of the box so that the buttons, potentiometers, and LEDs can be mounted and so that the speaker is not blocked.

Another hole must be drilled along the side of the box so that the Arduino's power cable does not keep it from closing fully.

Wiring:

Solder wires onto the terminals of all 8 buttons as well as the rotary and soft potentiometers.

Mounting:

The buttons and rotary potentiometer are attached to the box using the nuts that are included with purchase. The speaker is taped under the holes drilled for it from the inside of the box. The soft potentiometer is attached by peeling the cover off of the adhesive backing and pressing it onto the box. The LEDs are attached using hot glue.

Choosing Tones:

To pick our set of 8 notes we used http://www.liutaiomottola.com/formulae/freqtab.htm. The box plays an octave from A3-A4. Using the frequencies found via the link one could program many other sequences.

Code

Music Box Toy Code Arduino
const int butt0 = 0;
const int butt1 = 8;
const int butt2 = 2; 
const int butt3 = 3; 
const int butt4 = 4; 
const int butt5 = 5; 
const int butt6 = 6;  
const int butt7 = 7; 
const int pot = 2;
const int soft = 1;
const int buzzerPin = 12;

 
void setup() {
  //start serial connection
  Serial.begin(9600);
  pinMode(butt0, INPUT_PULLUP);
  pinMode(butt1, INPUT_PULLUP);
  pinMode(butt2, INPUT_PULLUP);
  pinMode(butt3, INPUT_PULLUP);
  pinMode(butt4, INPUT_PULLUP);
  pinMode(butt5, INPUT_PULLUP);
  pinMode(butt6, INPUT_PULLUP);
  pinMode(butt7, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);


}

void loop() {
  //read the pushbutton value into a variable
  int val0 = digitalRead(butt0);
  int val1 = digitalRead(butt1);
  int val2 = digitalRead(butt2);
  int val3 = digitalRead(butt3);
  int val4 = digitalRead(butt4);
  int val5 = digitalRead(butt5);
  int val6 = digitalRead(butt6);
  int val7 = digitalRead(butt7);
  int potVal = analogRead(pot);
  int full = potVal/4;
  int half = potVal/8;
  int softVal = analogRead(soft);
  int shift;
  Serial.println(softVal);

  if (softVal >= 15)
  {
    shift = (softVal - 500)/5;
  }
  else
  {
     shift == 0;
  }
  if (val0 == LOW) 
  {
    analogWrite(9, full);
    analogWrite(10, 0);
    analogWrite(11, 0);
    tone(buzzerPin, 220.6 + shift, 100);
  } 
  else if (val1 == LOW)
  {
    analogWrite(9, full);
    analogWrite(10, half);
    analogWrite(11, 0);
    tone(buzzerPin, 246.9 + shift, 100);
  }
  else if (val2 == LOW)
  {
    analogWrite(9, full);
    analogWrite(10, full);
    analogWrite(11, 0);
    tone(buzzerPin, 261.6 + shift, 100);
  }
  else if (val3 == LOW)
  {
    analogWrite(9, 0);
    analogWrite(10, full);
    analogWrite(11, 0);
    tone(buzzerPin, 293.7 + shift, 100);
  }
  else if (val4 == LOW)
  {
    analogWrite(9, 0);
    analogWrite(10, full);
    analogWrite(11, full);
    tone(buzzerPin, 329.6 + shift, 100);
  }
  else if (val5 == LOW)
   {
    analogWrite(9, 0);
    analogWrite(10, 0);
    analogWrite(11, full);
    tone(buzzerPin, 349.2 + shift, 100);
  }
  else if (val6 == LOW)
    {
    analogWrite(9, full);
    analogWrite(10, 0);
    analogWrite(11, full);
    tone(buzzerPin, 392 + shift, 100);
  }
  else if (val7 == LOW)
    {
    analogWrite(9, full);
    analogWrite(10, full);
    analogWrite(11, full);
    tone(buzzerPin, 440 + shift , 100);  
  }
  else
  {
    analogWrite(9, 0);
    analogWrite(10, 0);
    analogWrite(11, 0);
  }
}

Schematics

20180129_083139_lXv8xktQzA.jpg
20180129 083139 lxv8xktqza
20180126_121609_n61SXLpxH7.jpg
20180126 121609 n61sxlpxh7
wiring_diagram_2KL8Z1Mu6K.png
Wiring Diagram For The Project (Note: Buttons displayed are not the same as those used in the project)
Wiring diagram 2kl8z1mu6k

Comments

Similar projects you might like

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

Project tutorial by Isaac Wolf and Sarah Worthington

  • 808 views
  • 0 comments
  • 3 respects

Interactive LED Name

Project tutorial by Pedro Mendez and Daniel Jablonski

  • 1,887 views
  • 1 comment
  • 5 respects

Interactive Children's Jack-In-The-Box

Project tutorial by Team 10

  • 631 views
  • 0 comments
  • 4 respects

Fingerscan: Music at Your Fingertips

Project showcase by touchmysound

  • 9,340 views
  • 6 comments
  • 29 respects

Electron Music Box Buzzer App

Project tutorial by Iain

  • 1,753 views
  • 0 comments
  • 4 respects

Arduino Tutorial : Mini Piano

Project tutorial by the lonely programmer

  • 6,284 views
  • 2 comments
  • 8 respects
Add projectSign up / Login