6,536

101

9

For a long time, I've wanted to make a soundbox, which is something like this kind of site but in real life.

I suppose I'm not the first one to create such a box, but I never found one here, so I decided to publish it !

Hope you enjoy it, it's my first instructable, and don't be too harsh on the english mistakes for that's not my mother tongue.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Supplies

For this project, you'll need :

• 3mm pressed wood for the box
• arcade buttons such as this one or this one (I bought the last one)
• some toggle switches
• some wires
• an arduino uno
• a sparkfun mp3 player shield (here for amazon)
• a bunch of resistors for the buttons and the ground. I used 10k, 15k, 18k, 33k, 47k, 56k, 100k, 180k and 220k, plus a 470k

## Step 2: Preparation - the Box

The box has been created using a website like makercase. As the buttons have a diameter of 6cm, create a square box of 25 cm. The height of my box is around 15cm (take in account the space for the arduino, the cables, the speaker...)

Using Inkscape, coreldraw or Adobe Illustrator, create the holes on the top piece of the box. You may also want to add the names of the sounds you'll later link to each button. In a futur version, I'll add the holes for the power button.

## Step 4: The Buttons Wiring

As you might notice, we don't really have a lot of free pins to connect the buttons on the MP3 player shield, so we will have to use a really nice "trick", which is using an analog pin. It's really well explained in this ible.

You have to connect various resistors with different values in parallel the the +5V, then the button, then wire the button to the analog pin.

I used 10k, 15k, 18k, 33k, 47k, 56k, 100k, 180k and 220k, plus a 470k for the ground. Why these values ? Well... Those are the first one I found in my mess, and they happened to match pretty well.

You can see on the pictures my connections. As I'm not really good at soldering, I prefered to let it on the breadboard, but I'll change it to make the box smaller in the futur (the wires and the breadboard take a lot of space).

Once it's all hooked up, you can go on to the code. It's explained in the ible previously linked, but the idea, if you don't wish to (re)open it, is to read the value on the analog pin, and create cases that match every resistor. In my case, it was :

```if (val >= 920 && val <= 940)<br>  {
Serial.println("green");
}
else if (val >= 875 && val <= 895)
{
Serial.println("brown");
}
else if (val >= 860 && val <= 870)
{
Serial.println("red");
}
else if (val >= 690 && val <= 710)
{
Serial.println("orange");
}
else if (val >= 650 && val <= 670)

Serial.println("blue");
}
else if (val >= 504 && val <= 520)
{
Serial.println("yellow");
}
else if (val >= 760 && val <= 770)
{
Serial.println("pink");
}
else if (val >= 350 && val <= 370)
{
Serial.println("white");
}
else if (val >= 320 && val <= 330)
{
Serial.println("purple");
}
else
{
Serial.println(val);
}```

You might need to adapt it a little to match your values.

## Step 5: The MP3 Player Shield

If you have never played with this shield, I advise you to check the tutorials at sparkfun.

Anyway, You can find attached the code that runs on my project.

You might see the use of the pin number 10 in the code, it's in order to chose the "line" of sounds.

I decided that my box had to play more than only 9 sounds, so I added a toggle switch. When it's closed, the pin goes down, and the code adds 9 to the variable "song", allowing to play up to 18 songs in this configuration. It's totally possible to imagine adding buttons. 2,4,8,16,32... sets of songs...

## Step 6: The Power Supply

As for the power supply, I used a battery case with 3 slots for AA batteries. I wired the ground to the ground of the arduino, and the battery case power to a switch. The other pin of the switch goes to the Vin of the arduino.

As i was unable to use only one button for the arduino and the speaker, I dit the same thing with the speaker.

(I end up with two buttons that I have to push for the soundbox to work... I might work this out later.)

## Step 7: Conclusion

Once everything is wired, put it in the box, pray for it to stay in place, and play with your soundbox !

(Take it for a trip with a friend in your passenger seat, let him play with it, and you'll end up praying for the box to break...)

Thank you for reading it. I know, it needs some improvements (a lot), and I'll go back to adding this on the instructables later :)

I entered the "First Time Author Contest", so, please, if you liked this project, consider voting for it ! :)

Participated in the
Epilog Contest VII

Participated in the
First Time Author Contest

112 8.1K
72 6.3K
183 11K

## 9 Discussions

How can I stop the music in the middle of execution? Just cutting off the power? And if Yes, is there any problem doing that?

That's a great question, thank you for asking !

I don't think there would be any problem in cutting off the power, but the arduino takes a little bit of time to boot once it's powered.

You should simply add a button (directly to a digital pin, or with the analog thing explained in the instructable) and, when it's pressed, call the function "MP3player.stopTrack();", it will stop any track currently playing :)

Thank you very much! I didn't know about the existence of this function. By the way, your instructable is awesome!

:-)

thats Great, it is nowon my to do list, probably in the top 10 of my todo list.

Thanks for sharing