|
12345678910111213141516171819202122232425262728293031323334 |
- // Simple demo of the Stream parsInt() member function.
- #include <SdFat.h>
-
- // SD card chip select pin - Modify the value of csPin for your SD module.
- const uint8_t csPin = 10;
-
- SdFat SD;
- File file;
- //------------------------------------------------------------------------------
- void setup() {
- Serial.begin(9600);
-
- // Initialize the SD.
- if (!SD.begin(csPin)) {
- Serial.println(F("begin error"));
- return;
- }
- // Create and open the file. Use flag to truncate an existing file.
- if (!file.open("stream.txt", O_RDWR|O_CREAT|O_TRUNC)) {
- Serial.println(F("open error"));
- return;
- }
- // Write a test number to the file.
- file.println("12345");
-
- // Rewind the file and read the number with parseInt().
- file.rewind();
- int i = file.parseInt();
- Serial.print(F("parseInt: "));
- Serial.println(i);
- file.close();
- }
-
- void loop() {}
|