Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

44 rindas
1.1KB

  1. // Simple demo of the Stream parsInt() member function.
  2. #include <SPI.h>
  3. // The next two lines replace #include <SD.h>.
  4. #include "SdFat.h"
  5. SdFat SD;
  6. // SD card chip select pin - Modify the value of csPin for your SD module.
  7. const uint8_t csPin = SS;
  8. File file;
  9. //------------------------------------------------------------------------------
  10. void setup() {
  11. Serial.begin(9600);
  12. // Wait for USB Serial.
  13. while(!Serial) {
  14. SysCall::yield();
  15. }
  16. Serial.println(F("Type any character to start"));
  17. while (!Serial.available()) {
  18. SysCall::yield();
  19. }
  20. // Initialize the SD.
  21. if (!SD.begin(csPin)) {
  22. Serial.println(F("begin error"));
  23. return;
  24. }
  25. // Create and open the file. Use flag to truncate an existing file.
  26. file = SD.open("stream.txt", O_RDWR|O_CREAT|O_TRUNC);
  27. if (!file) {
  28. Serial.println(F("open error"));
  29. return;
  30. }
  31. // Write a test number to the file.
  32. file.println("12345");
  33. // Rewind the file and read the number with parseInt().
  34. file.seek(0);
  35. int i = file.parseInt();
  36. Serial.print(F("parseInt: "));
  37. Serial.println(i);
  38. file.close();
  39. }
  40. void loop() {}