Random MP3/Wav player

Hi there,
I’m a first time poster here, so I apologize in advance if this is in the wrong spot.

I have a project I’d like to make, and the Arduino came to mind as a possibility to make it happen. I am looking for any advice, or even if the Arduino is overkill for this, I am hoping someone will let me know.

I have a vintage pay phone I cannot make work with my current phone system, so at the advice of a friend I’ve decided to make it a “novelty” so it doesn’t go completely unused. He suggested making the phone play something through the handset when it is picked up.

After some thought, I thought it might be cool to have it play a random sound through the earpiece when picked up, and stop when it is hung up. In the phone that I am using, a leaf switch is open when the handset is in the cradle. The leaf switch closes when the handset is picked up.

I did some research, and found lots of little audio players, but none had the capability to play a random sound, and the switching is an issue as well. When the phone is hung up, the sound would continue to play.

I thought an Arduino could be a possible platform to make this happen, and if so, I was hoping someone here could point me in the direction of where to start.

Would the MP3 shield be a requirement to make this happen?

I’m a software developer, and electronics is my hobby, so writing any code and soldering up boards isn’t a problem.

Any help from the group is appreciated! Thanks in advance…


Look at arduino tone library. http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation#Arduino_Core_Version

About MP3 shield i guess u were talking about this ? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1259561121/0

I did some research, and found lots of little audio players

What if u emulate button presses with arduino? It might have some delay but should work.

That's one of them... here's the one I saw: http://www.sparkfun.com/products/9736

As far as the tone library, while that is pretty cool, I really wanted this to play a random .WAV or .MP3 file (doesn't matter which). I'm assuming the files would be stored on an SD card, and code would randomize a file from a folder on the card.

When the receiver picks up (switch closed), I want a random sound file to begin playing. When the receiver is placed back down (switch open), I want that file to stop playing.


You can use random() function to generate a random tune number. Read this page:


You can use a wave shield to store a few tunes, then use random() to pick one at random to play.

The switch is easy. Connect one end of the switch to arduino ground and the other end to an arduino input say digital pin 2. Set that pin as input with internal pullup resistor. Then keep reading that input. If it becomes low then pick a tune at random and play it.

I don't have a wave shield so someone else could help you on how to stop a tune.

Sounds like a fun project.