您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.1KB

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