Go Down

Topic: File navigation on SD card (Read 1 time) previous topic - next topic

wiltors42

I'm wondering if the Arduino MP3 shield library is capable of file browsing an SD card. For example, on screen would be displayed the contents of a directory, and the user could use buttons to browse through directories and MP3 files on the SD volume.

wanderson

You don't specify which Arduino MP3 Shield library your talking about, but if it is this one (or one like it); https://github.com/madsci1016/Sparkfun-MP3-Player-Shield-Arduino-Library/tree/master/ then it is using the SDfat library to provide access to the SD card.  That library is the ancestor from which the Arduino SD library comes from and you can probably use this example (which may need some modification to work with your shield library) to implement a directory browsing feature:

Code: [Select]
#include <SD.h>

File root;

void setup()
{
  Serial.begin(9600);
  pinMode(10, OUTPUT);

  SD.begin(10);

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");
}

void loop()
{
  // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs) {
   while(true) {

     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       Serial.println("**nomorefiles**");
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
   }
}


Some more information on the SDFat library that may be helpful is available from:
http://arconlab.com/lab/Arduino/Library/SD%20Reader%20-%20Fat32/html/class_sd_file.html
and
http://arconlab.com/lab/Arduino/Library/SD%20Reader%20-%20Fat32/html/

Taufiq_Umar

Hi wanderson..
I have 2 questions about your post :

1. Is arduino connected to DfMiniPlayer ?
2. Is pin 10 connected to Rx DfMiniplayer ?

Thanx in advance

Go Up