Go Down

Topic: List SD directory contents using native library? (Read 9120 times) previous topic - next topic

tbkdan

Hi, I'm currently planning my first Arduino app and making sure I have all my ducks in a row before I get into the nitty gritty (my mega should be arriving in a few hours  XD). First, let me start with what I want to do. My goal is to have text files on an SD card that the Arduino can read and use the contents as parameters. The tricky part is that there will be many files to select from, and the names of the files will not be known ahead of time (I am planning to use an LCD and some selection buttons to choose the files from a list).

I was looking at Sparkfun's SDfatlib examples and saw their example to list the contents of a directory, which I could use and then execute the getFilename() to figure out what the names of the files are, store that in an array, and then use the file names to actually open the files when the time comes. After poking around some more, I also see that Arduino now has their own SD library. However, I do not see any mechanisms for listing the contents of a directory. Is this possible with the "native" SD library or should I stick with SDfatlib?

ThisIsMyName

Look at the example on http://arduino.cc/en/Tutorial/CardInfo
You can use
Code: [Select]
  root.openRoot(volume);
 
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);

to view files on a card

Go Up