This repository has been archived on 2020-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
arduino_universal_serial_ad.../Libraries/AdafruitLogger/SdFat/examples/OpenNext/OpenNext.ino

38 lines
1,018 B
Arduino
Raw Permalink Normal View History

/*
* Open all files in the root dir and print their filename and modify date/time
*/
#include <SdFat.h>
// SD chip select pin
const uint8_t chipSelect = SS;
// file system object
SdFat sd;
SdFile file;
// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
while (!Serial) {} // wait for Leonardo
delay(1000);
// initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
// breadboards. use SPI_FULL_SPEED for better performance.
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
// open next file in root. The volume working directory, vwd, is root
while (file.openNext(sd.vwd(), O_READ)) {
file.printName(&Serial);
cout << ' ';
file.printModifyDateTime(&Serial);
cout << endl;
file.close();
}
cout << "\nDone!" << endl;
}
//------------------------------------------------------------------------------
void loop() {}