MP3 Player Shield Music Box a
learn.sparkfun.com tutorial
Available online at: http://sfe.io/t21
Contents
Tardis Music Box Project
Parts List
Circuit Diagram
Example Code
See it in Action!
Tardis Music Box Project
Got a few favorite things that you need to keep safe? A custom music box is a fun project to house
anything ranging from necklaces to sonic screwdrivers. In this tutorial, you will see the basic
instructions and parts used in making this fan-made Doctor Who TARDIS (Time and Relative
Dimension in Space) music box. This can be used as a starting point for your own music box,
TARDIS, or mischievous creation.
Page 1 of 6
Here is a list of other tutorials you might find helpful while following this tutorial:
MP3 Player Shield
Mono Audio Amplifier Quickstart Guide
LED Current Limiting Resistors
Arduino Main Board Quickstart Guide
Parts List
TARDIS Fan-based Music Box SparkFun Wish
List
Page 2 of 6
Micro Metal Gearmotor 100:1 (Sale)
ROB-08910
This motor has a long (0.365" or 9.27 mm), D-shaped metal output shaft that matches the Pololu wheel 42x19m…
SparkFun Mono Audio Amp Breakout - TPA2005D1
BOB-11044
This tiny audio amplifier is based on the Texas Instruments TPA2005D1. Its efficient class-D operation means …
SparkFun MP3 Player Shield
DEV-10628
This new revision of the SparkFun MP3 player shield retains the awesome MP3 decoding abilities of the last v…
Diffused LED - White 10mm
COM-11121
Check out these big 10mm through-hole LEDs! The opaque epoxy package causes these LEDs to have a soft…
Reed Switch
COM-08642
This is a small device called a [reed switch](http://en.wikipedia.org/wiki/Reed_switch). When the device is expo…
Arduino Uno - R3
DEV-11021
This is the new Arduino Uno R3. In addition to all the features of the previous board, the Uno now uses an ATm…
You will also need a box of some sort. This is where the fun starts! You can use tons of different
Speaker - 0.5W (8 Ohm)
types of materials
ranging from wood to plastic. For this project, a laser cutter was used to make
COM-09151
A
small
audio
speaker
that is ideal
for would
radio andhave
amplifier
projectstoo.
and is small enough to fit in robot projects. **F…
cut-outs from soft wood.
A crafter
knife
worked
9V Battery Holder
Circuit Diagram
PRT-10512
This 9V battery holder allows your battery to snap in tight and holds it in place, which is great in situations whe…
9V Alkaline Battery
PRT-10218
These are your standard 9 Volt alkaline batteries from Rayovac. Don't even think about trying to recharge thes…
Hook-up Wire - Black (22 AWG)
PRT-08022
Standard 22 AWG solid Black hook up wire. Use this with your bread board or any project in which you need s…
Hook-up Wire - Red (22 AWG)
PRT-08023
Standard 22 AWG solid Red hook up wire. Use this with your bread board or any project in which you need stu…
Break Away Headers - Straight
PRT-00116
A row of headers - break to fit. 40 pins that can be cut to any size. Used with custom PCBs or general custom h…
Magnet Square - 0.25"
COM-08643
These are small rare earth magnets - 0.25" cubed. Composed of Neodymium/Iron/Boron (NdFeB), these magn…
View TARDIS Fan-based Music Box on SparkFun.com
You will need to put the reed switch near the opening doors of your box/case, and a magnet on the
Page 3 of 6
other side, so when the box is closed the magnet and the reed switch are right next to each other.
Based on your project, you may consider different types of switches instead of a reed switch. If you
have a smaller box, you might want to check out the other sound modules we carry. For example:
an Audio-Sound Breakout - WTV020SD with an Arduino Pro Mini 3.3V as the development board.
Please keep in mind when changing the parts to get the appropriate motors and power supply.
Example Code
//SFEMP3Library author Bill Porter
//SFEMP3Library author Michael P. Flaga
/* MP3 Player Shield Music Box Code Example:
SparkFun Electronics, Pamela, 1/24/2013
Beerware License
Hardware Connections:
-LED = D3 on MP3 Player Shield;
-Motor = D5 on MP3 Player Shield;
-Reed Switch = D4 on MP3 Player Shield;
-Mono Audio Amp Breakout Board Shutdown Pin = D10 on MP3 Player Shield;
You will need to solder header pins to the MP3 Player Shield.
Put the shield on top of an Arduino Uno.
Usage:
When the door opens, the motor will spin and a sound file will play.
The sound file will loop.
Then when the door closes the motor stops spinning and a new track plays one time. */
#include <SPI.h>
//Add the SdFat Libraries
#include <SdFat.h>
#include <SdFatUtil.h>
//and the MP3 Shield Library
#include <SFEMP3Shield.h>
SFEMP3Shield MP3player;
int led = 3;
int motor = 5;
int reedSwitch = 4;
int speaker = 10;
int fadeAmount = 5;
int brightness = 0;
boolean active = false;
void setup() {
pinMode(motor, OUTPUT); //Motor
pinMode(led, OUTPUT); // LED
pinMode(reedSwitch, INPUT); //Reed Switch
pinMode(speaker, OUTPUT); //Speaker Enable
analogWrite(led, 0); //LED off
Page 4 of 6
digitalWrite(reedSwitch, HIGH); //turn on internal pullups for reed input
digitalWrite(motor, LOW); //Motor off
MP3player.begin();
MP3player.SetVolume(0x00, 0x00); //set volume
}
void loop() {
if (digitalRead(reedSwitch) == HIGH && !active)//when door opens
{
active = true;
analogWrite(led, 80);
digitalWrite(speaker,HIGH);
digitalWrite(motor, HIGH);
MP3player.stopTrack();
MP3player.playTrack(3);
}
else if (digitalRead(reedSwitch) == LOW && active)//when door closing
{
active = false;
MP3player.stopTrack();
MP3player.playTrack(2);
digitalWrite(motor, LOW);
analogWrite(led, 255);
}
else if (digitalRead(reedSwitch) == LOW) //while door is closed
{
analogWrite(led, 0);
digitalWrite(motor, LOW);
}
else
{
MP3player.playTrack(1);
analogWrite(led, brightness);
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount;
}
brightness += fadeAmount;
}
delay(100);
}
Libraries
See it in Action!
Page 5 of 6
As with any DIY project, you should always customize and tweak what you want for maximum
awesomeness!
There was a lot of lessons learned in this Demo Project. The biggest one is to have patience with
the wood glue. As you can see little nails were used in place due to lack of time/patience. If you are
making a project like this one as a gift with limited time, remember to KISS! (Keep It Simple, Stupid!)
If you liked this project, you might want to check out theElevator TARDIS tutorial too!
learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado
Page 6 of 6
© Copyright 2026 Paperzz