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.

47 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. while (file.openNext(sd.vwd(), O_READ)) {
  26. file.printFileSize(&Serial);
  27. Serial.write(' ');
  28. file.printModifyDateTime(&Serial);
  29. Serial.write(' ');
  30. file.printName(&Serial);
  31. if (file.isDir()) {
  32. // Indicate a directory.
  33. Serial.write('/');
  34. }
  35. Serial.println();
  36. file.close();
  37. }
  38. Serial.println("Done!");
  39. }
  40. //------------------------------------------------------------------------------
  41. void loop() {}