Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

47 lines
1.1KB

  1. /*
  2. * Read the logfile created by the eventlog.ino 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)) {
  21. sd.initErrorHalt();
  22. }
  23. // set current working directory
  24. if (!sd.chdir("logs/2014/Jan/")) {
  25. sd.errorHalt("chdir failed. Did you run eventlog.ino?");
  26. }
  27. // open file in current working directory
  28. ifstream file("logfile.txt");
  29. if (!file.is_open()) {
  30. sd.errorHalt("open failed");
  31. }
  32. // copy the file to Serial
  33. while ((c = file.get()) >= 0) {
  34. cout << (char)c;
  35. }
  36. cout << "Done" << endl;
  37. }
  38. //------------------------------------------------------------------------------
  39. void loop() {}