All the files for our music box can be found here: http://lauralippincott.com/musicbox
Here's the Sketchup file I have for us to start from. It has a cutout for each component, and interlocking box joints that require no glue or nails. We'll need to build a linkage to lift the lid, and a dancer to spin on the continuous rotation servo. Basel has composed a melody for us using the Pitches library.
#include "pitches.h"
// notes in the melody:
int melody[] = { NOTE_D3, NOTE_F3, NOTE_A3, NOTE_G3,
NOTE_C3, 0, NOTE_C3, NOTE_D3, NOTE_F3,
NOTE_A3, NOTE_D3, NOTE_F3, NOTE_A3,
NOTE_G3, NOTE_C3, 0, NOTE_C3, NOTE_F3,
NOTE_F3, NOTE_A3 };
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = { 34, 20, 20, 25, 45, 20, 20, 30,
40, 30, 55, 23, 56, 40, 35, 23, 67, 5 };
void setup(){
}
void loop(){
for (int thisNote = 0; thisNote < 18; thisNote++) {
int noteDuration = 1000/noteDurations[thisNote]; // one second divided by note duration
tone(8, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8); // stop the melody
delay(1000); // pause for a second
}
}