Introduction: Music Player

Hello,

In this instructable I'm going to show you how to make a simple music player using an Arduino and a SD card reader. It is quite simple to use and is fun to make. Note: This is just for fun and not for serious use. I tried this mainly to learn how to use SD card on Arduino.

Step 1: Components Required

  • 1* Arduino (I used Uno)
  • 1* SD card
  • 1* SD card reader for Arduino (I use LC Studio)
  • 8* Jumper cables Male - Female
  • A couple of Male - Male jumper cables
  • 3* Push Buttons (tactile switches) (as the controls for the music player)
  • 3* 10 k ohm resistors
  • 1* Breadboard
  • 1* Speaker (low wattage speaker that doesn't need separate power - see the attached picture)

Step 2: Making the Player

Create the circuit as shown in the fritzing image above. Make sure you wire the SD card reader correctly as you don't want to risk damaging your SD card. Here are all the SD card connections. (You don't need to worry about these if you are using a SD shield, but if you are using a module you need to wire it up.)

+-----------+---------------------------------+
| SD module | Arduino (UNO) | +-----------+---------------------------------+ | Gnd | Gnd | | 3.3v | 3.3v | | 5v | 5v | | CS | pin 4 (Pin 53 on Arduino Mega) | | MOSI | pin 11 (Pin 51 on Arduino Mega) | | SCK | pin 13 (Pin 52 on Arduino Mega) | | MISO | pin 12 (Pin 50 on Arduino Mega) | | Gnd | Gnd | +-----------+---------------------------------+

Additionally, the speaker connection should be as follows:

  • Speaker - Pin 9 (Pin 11 on Arduino Mega) (This is required for TMRpcm library that is used with this code)

The switches should be connected to pin 5, 6, 7 (Respectively - Rewind to first file, Play, Next File).

The code which I have written requires TMRpcm library (you need to download it from https://github.com/TMRh20/TMRpcm/archive/master.zip)

Go to the Arduino IDE. Include the downloaded library by going to Sketch > Include Library > Add Zip file.

Now upload the code given below onto your Arduino board.

Note : If you are using Arduino Mega, you need to make 2 changes in the code.
1. Use pin 11 as speaker pin instead of pin 9. 2. Use pin 53 as CS pin instead of pin 4.

Step 3: Prepare the SD Card

Now you need to format the SD card. Format it according to the instructions given in the link below:

https://www.arduino.cc/en/Reference/SDCardNotes

Once you have formatted the SD card, you need to put in a few music files. The libraries I have used only support .WAV files.

If you don't have WAV files, you can use the link below to convert your mp3 to WAV. The library supports files with 8-32 khz Sample Rate (I used 16 kHz), 8 bit per sample, mono channel.

http://audio.online-convert.com/convert-to-wav

Since I had used FAT system, I had to rename the WAV file to 8.3 format (you may need to do the same). Then copy the files into the SD card.

Step 4: Use It!!

Plug in your SD card into the reader and connect your Arduino to your PC/Comp. Click on Serial Monitor and after a few seconds the first music file's name on your SD card will appear. To move to the next file press the push button connected to pin 7. To go to the first file press the button connected pin 5. To play a file press the button connected to pin 6. And that's it, enjoy!!!

Please note that I used only 3 controls (Go to first file, Next file, Play), but you can obviously use more controls as you wish. Of course, you would need to modify the program accordingly.

PS- Thanks a lot for looking at my write up. If you have any suggestions please do tell me.

If you liked this instructable, have a look at my other instructables.

Simple and Cheap Motor Driver Board for Arduino

Hit the target game - a nice timepass

Comments

author
alaafprojs (author)2017-01-01

cool! I'm trying it...

author
rajdey (author)2016-06-12

Thanks for the instructions. Your code is very simple and easy to understand. No compilation error. Also the HW circuit is described very well.

But, I'm getting noise at the output (speaker). However, the noise are different for different track/.wav file. Is there any filter required at the output or any spec required for the speaker ?

N.B : Prev / Play / Fwd buttons are working fine and giving result at the serial monitor.

author
Tanmay Deuskar (author)rajdey2016-06-13

It is possible that the volume is too high. The TMRpcm library supports volume between 1-7 (I've chosen 5), but as you increase the volume the clarity decreases drastically. When I was making the circuit whenever I set the volume above 5 I'd have the same kind of problem. Search for the line "Audio.setVolume(5)" and change the 5 to a lower value.

If it doesn't work tell me.

BTW if it works and the volume is too low you can simply ad a transistor amplifier circuit to the speaker.

thanks

author
rajdey (author)Tanmay Deuskar2016-06-13

Dear,
Thanks for the reply. I've tried as per your suggestion. But it's not working. Could you please give me your speaker spec. Because I'm using a very small speaker (from a cheap toy) of 20mm dia.

Thanks.

author
Tanmay Deuskar (author)rajdey2016-06-14

Hello,

Well, I'm using an 8 ohm, 3W speaker and it works fine. I think you should use a speaker with values around that.

Thanks.

author
CritBrassGene (author)2016-06-08

can i put an audio jack instead of sd card? or that wont work?

author

Of course you can use an Audio jack to connect to the speakers, but you need a SD card to allow the Arduino to access the music files to play them. Without a SD card the Arduino can't play music files. Hope you find this reply useful, if not please ask.

author
erysoft (author)2016-06-07

Hi,

You have no problems with the SD Card? With this SD Card board, UNO send +5V controls (MOSI, SCK,CS\), and normaly this controls must be no higher that +3.3V. Normaly, this action destroy the SDCARD.

Sorry, I have a very bad English

author
Tanmay Deuskar (author)erysoft2016-06-09

Well I've an LC studio SD reader, and it supports 5v. Most SD shields and modules allow 5v (they must have an inbuilt voltage regulator). Eg - Cooking Hax, Ethernet Shiled etc

author
PiotrK15 (author)2016-06-08

Well sb can give me good speaker links?

author
Saiyam (author)2016-06-07

Looks easy and fun to make!

About This Instructable

9,491views

156favorites

More by Tanmay Deuskar:Video Game Controller With ArduinoThe Attiny85/45 Capacitor TesterDIY H-Bridge Shield for Arduino With Transistors
Add instructable to: