Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

48 linhas
1.2KB

  1. /*
  2. * Print size, modify date/time, and name for all files in root.
  3. */
  4. #include <SPI.h>
  5. #include "SdFat.h"
  6. // SD chip select pin
  7. const uint8_t chipSelect = SS;
  8. // file system object
  9. SdFat sd;
  10. SdFile file;
  11. //------------------------------------------------------------------------------
  12. void setup() {
  13. Serial.begin(9600);
  14. while (!Serial) {} // wait for Leonardo
  15. delay(1000);
  16. Serial.println();
  17. // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  18. // breadboards. use SPI_FULL_SPEED for better performance.
  19. if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
  20. sd.initErrorHalt();
  21. }
  22. // Open next file in root. The volume working directory, vwd, is root.
  23. // Warning, openNext starts at the current position of sd.vwd() so a
  24. // rewind may be neccessary in your application.
  25. sd.vwd()->rewind();
  26. while (file.openNext(sd.vwd(), O_READ)) {
  27. file.printFileSize(&Serial);
  28. Serial.write(' ');
  29. file.printModifyDateTime(&Serial);
  30. Serial.write(' ');
  31. file.printName(&Serial);
  32. if (file.isDir()) {
  33. // Indicate a directory.
  34. Serial.write('/');
  35. }
  36. Serial.println();
  37. file.close();
  38. }
  39. Serial.println("Done!");
  40. }
  41. //------------------------------------------------------------------------------
  42. void loop() {}