No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

41 líneas
1.1KB

  1. /*
  2. * Read the logfile created by the eventlog.pde example.
  3. * Demo of pathnames and working directories
  4. */
  5. #include <SPI.h>
  6. #include <SdFat.h>
  7. // SD chip select pin
  8. const uint8_t chipSelect = SS;
  9. // file system object
  10. SdFat sd;
  11. // define a serial output stream
  12. ArduinoOutStream cout(Serial);
  13. //------------------------------------------------------------------------------
  14. void setup() {
  15. int c;
  16. Serial.begin(9600);
  17. while (!Serial) {} // wait for Leonardo
  18. // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  19. // breadboards. use SPI_FULL_SPEED for better performance.
  20. if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
  21. // set current working directory
  22. if (!sd.chdir("LOGS/2011/JAN/")) {
  23. sd.errorHalt("chdir failed. Did you run eventlog.pde?");
  24. }
  25. // open file in current working directory
  26. ifstream file("LOGFILE.TXT");
  27. if (!file.is_open()) sd.errorHalt("open failed");
  28. // copy the file to Serial
  29. while ((c = file.get()) >= 0) cout << (char)c;
  30. cout << "Done" << endl;
  31. }
  32. //------------------------------------------------------------------------------
  33. void loop() {}