Introduction: $20 Holiday Cheer Box

This project will show you how to build a box that plays a random sound when the button is pressed. In this case, I used it to build a box that I can strategically place around the office during the holidays. When people press the button they hear a short holiday themed sound clip which will either cheer them up or annoy them depending on how they feel about the holidays.

However, you can use it for other things as well. I have also used this same design to make my own doorbell which plays random doorbell sounds. It's a great way to add sound to any project.

This is very similar to my Secret Code Box project, but only a button this time and no keypad.

Step 1: Parts

I was able to reuse most of these parts from stuff I had taken apart or saved over the years, so my actual cost was only $9 for the Nano and Sound Module.

Step 2: Load Your Sound Files

Scour the internet to find some sound clips that you want to use and download them to your computer. I have found that these sound modules like constant bitrate for the mp3 compression and 44100 samle rate on the audio file. If you aren't sure your sound files conform to these specs you can use an audio editing program like Audacity to open the file and then save it back out with the right settings. You can also use Audacity to cut down longer sound clips to something that suits your needs.

Connect the sound module to a USB port and it should show up as a small USB drive. Tranfer you sounds over making sure they are named 0001.mp3, 0002.mp3, 0003.mp3 and so on. This is important for the sound module to be able to play them.

Step 3: Assemble Your Components

Drill a hole in your project box and afix the button. You might also want to drill some holes where you mount your speaker so the sound can be heard more clearly. Drill another hole for the usb cable to go through. Cut the end off of the USB cable and feed it through the hole. Tie a knot in the usb cable for strain relief and to prevent the cable from pulling back through the hole.

Connect the components as shown in the image. Connect the red wire on the USB cable to VIN on the Arduino and the black wire to GND. Depending on the sound module you buy, the pinout might be different, so be sure to check the documentation or do some research online to find the right pinout. Luckily for me, the ebay seller posted the pinout with the item listing.

Step 4: Code

You will need to download and install an Arduino library for the sound module.

https://github.com/Critters/MP3FLASH16P/archive/master.zip

There are some good instructions on the github page that you might want to read as well.

https://github.com/Critters/MP3FLASH16P

The code for the project itself is quite simple. Connect the Arduino Nano to your computer and upload this script.

#include <Wire.h>
#include "SoftwareSerial.h" #include "MP3FLASH16P.h" MP3FLASH16P myPlayer;

void setup() { pinMode(12, INPUT_PULLUP); myPlayer.init(3); // Randomize the randomness randomSeed(analogRead(A0)); }

void loop() { if (digitalRead(12) == LOW) { // random(1,19) where 19 is 1 greater than the number of sound files // Change the last number to a volume level between 1 - 30 myPlayer.playFileAndWait(random(1, 19), 25); } }

Step 5: Take It Further

Hopefully your box is working now, and playing some fun sounds. Now try dressing it up a bit by adding some leds or decorations. Perhaps turn it into an ornament that hangs on your tree. I added a big glowing red LED button to mine and I am in the process of adding some antlers to the sides :)

Arduino Contest 2017

Participated in the
Arduino Contest 2017