Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

35 lines
862B

  1. // Simple demo of the Stream parsInt() member function.
  2. #include <SdFat.h>
  3. // SD card chip select pin - Modify the value of csPin for your SD module.
  4. const uint8_t csPin = 10;
  5. SdFat SD;
  6. File file;
  7. //------------------------------------------------------------------------------
  8. void setup() {
  9. Serial.begin(9600);
  10. // Initialize the SD.
  11. if (!SD.begin(csPin)) {
  12. Serial.println(F("begin error"));
  13. return;
  14. }
  15. // Create and open the file. Use flag to truncate an existing file.
  16. if (!file.open("stream.txt", O_RDWR|O_CREAT|O_TRUNC)) {
  17. Serial.println(F("open error"));
  18. return;
  19. }
  20. // Write a test number to the file.
  21. file.println("12345");
  22. // Rewind the file and read the number with parseInt().
  23. file.rewind();
  24. int i = file.parseInt();
  25. Serial.print(F("parseInt: "));
  26. Serial.println(i);
  27. file.close();
  28. }
  29. void loop() {}