The SD structure

In this post I'll try to explain a little the code of  our 'Jukebox' Arduino hearted .
The main problem I found for this project, was the limitation SD library, with reduced FAT which only allowed the names in 8.3 format.
The solution was to create a small catalog in a text file from which to read the entries.

The directory structure on the SD has the following format:
raiz
 +-artistas.txt
 +-[ARTIST01]
 |   +-album.txt
 |   +-[ALBUM01]
 |   |   +-track.txt
 |   |   +-track001.mp3
 |   |   +-track002.mp3
 |   |   .....
 |   |   +-track0nn.mp3
 |   +-[ALBUM02]
 |   .......
 |   +-[ALBUMnn]
 +-[ARTIST02]
 .....
 +-[ARTISTnn]

This means there are three levels: artist, album and track. Each level has a text file with the catalog entries (a line of text for each artist, album or song).
The names of the folders and files must be such as are in the scheme (you can always change the code).
It's a bit cumbersome to create the card, but ... worthwhile. I used a program that makes it much easier MP3Tag, enabling export to text tracks of a directory and rename mp3.


The code

It consists of a library 'AGMp3' handling the chip and SD, and the sketch of the player. You can download it from here

The library is responsible for the initialization of the chip, the SD bus and SPI. It has methods to write / read in the records of the chip, and to play an mp3.
As for the sketch starts reading file 'artistas.txt' located in the root of the SD and then through the encoder and buttons 'navigate' for the directory structure. At each level reads the corresponding text file to load the list of catalog. In the last level play the selected mp3.
Once being played, the encoder is responsible for varying the volume which is displayed on the LCD with a value of 0 to 10.
The Forward button go to the next song during playback.

To show the progress of the song, I have defined some characters on the LCD.


Here you have some pictures of the construction process

Hope you like it! ....




If you liked it, remember to share it on your favorite social network. Thanks

26 comments

November 26, 2012 at 12:23 AM

Thank you for blogging this useful project.

November 26, 2012 at 8:11 AM

Thank you. I'm glad you have been useful

March 4, 2013 at 5:45 PM

Can I download full your code and lib? thank you!

March 4, 2013 at 6:42 PM

@Hùng BV
The code is here

May 3, 2013 at 12:13 PM

Hi Guay,

How about adding the 3x4 keypad to control the volume, mute, or other button function? it seems the arduino not pin out enough. Is't right?

June 17, 2013 at 7:15 PM

Saludos por su proyecto MP3, lo he montado ya tengo el hardware listo pero me da error en la tarjeta, pienso que es por lo el formato o lo el archivo te textos en el sd card, agradecería tu ayuda.
Wilder padilla

June 18, 2013 at 7:50 AM

@Wilder Padilla
Que tipo de error?
La SD tiene que estar formateada con FAT32, y el archivo de texto tiene la estructura comentada.
Cuidado con la SD, si la tienes con cables. Yo tuve problemas utilizando cable plano y tuve que cambiar a un cable trenzado.
Los mp3 creo recordar que no pueden estar a más de 160 Kbp

June 20, 2013 at 1:43 AM

El error estaba en la conexión ya funciona y muy bien, felicitaciones y gracias por publicar el proyectó me fue de mucha utilidad.
Hasta otra oportunidad Wilder Padilla.

September 14, 2013 at 2:15 AM

Realmente tu proyecto me parece fantástico, quiero realizar un reproductor también con una tarjeta arduino uno un LCD DE 2x16 y una tarjeta mp3 como la que te muestro en el siguiente link
http://www.electronica.com.ve//ventas/catalog/product_info.php?cPath=83&products_id=2882
esta ya tiene la ranura para tarjeta SD incorporada mi problema es el código te agradecería si me puedes ayudar en fritzing hay un proyecto pero creo que el código no sirve
este es el link
http://fritzing.org/projects/connecting-a-sparkfun-mp3-shield-and-a-qy-1602-or
gracias y saludos

September 19, 2013 at 4:58 PM

@Kaled Souky
En teoría el código te debería valer el mismo. Esta placa tiene el decodificadro de MP3 y la SD en la misma placa, pero por lo demás no cambia. Tienes que prestar atención a los pines que se utilizan para seleccionar el chip y la SD (mira la tabla que hay en la primera parte) y al resto de pines de control. Por lo que he podido ver en el esquema de la placa, la correspondencia con los pines del Arduino son los mismos, pero revísalo bien.

December 3, 2013 at 5:54 PM

Good evening!
I need your help. I read the code with Arduino Program (1.0.2 and 1.0.4) but I have problems with visualization of some characters. For example the line:
if (letra == '�') {
letra = 'n' +125;
}
I have the same problem with other lines.
Please can you help me?
Thank you!
My email is:
antonio.filoni@inwind.it

December 3, 2013 at 7:36 PM

@nio19691969
Is a Arduino ide problem with no ASCII characters
(letra == '�') ==> (letra == 'ñ')

Other lines ?

December 4, 2013 at 2:31 PM

Hi, and many thanks for your fast reply.
May i have your email so i can send to you entire sketch?
I have another question. With VS1053 instead of VS100x module it's possible play flac files with your player?.
Again thank you!!!!
Antonio

December 6, 2013 at 4:44 PM

@nio19691969
Yes, you can sent me teh sketch.
I do not know if you can play 'flac'. In the code you will have to change the extension (now looking mp3). The rest should work, because the file is read and sent to VS100X in packets of 32 bytes.

December 6, 2013 at 11:35 PM

Hi, and many thanks for your reply.
The sketch iso too long for the post. (maximum 4.096 characters)
Have you got an email?
Thank you.
Antonio

December 7, 2013 at 11:33 AM

@nio19691969
Yes arduino.guay@gmail.com

January 9, 2014 at 4:50 PM

how to create the directory structure ?

January 27, 2014 at 4:09 PM

@onlineshop
Manually.

May 6, 2014 at 3:48 PM

If I delete the Part of LCD Code it still work?

May 7, 2014 at 9:32 AM

@PatriotaML
Yes, you could use two buttons to move to the next or previous song, as in the simple mp3 players.

March 28, 2015 at 12:56 PM

GOOD!

February 11, 2016 at 11:06 AM

I made this system, but I'm facing problem.
Could you share the examples of "artistas.txt", "album.txt", and "track.txt". many thanks.

February 11, 2016 at 9:10 PM

@Banker king
Here's an example
SD Example

February 12, 2016 at 12:03 PM

Thanks a lot for quick reply, I'm very happy now.

April 8, 2016 at 11:22 AM

Hope this MP3 ID3 tag editor helps, too.

December 7, 2016 at 1:32 AM

Everything looks almost ok but the system doesn't play the music when I choose it on lcd.
By the way I'm using the sparkfun mp3 shield. When I choose a track its name just moves up on the screen.
And also my mp3 module connected not with 3.3V as it shown on the image but with 5V because with 3.3V it doesn't get power up.

Post a Comment

Topics

Popular Posts

Versión española

Versión española
Arduino es Guay!!

Follow in Facebook

Powered by Blogger.