1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-04 15:24:12 +01:00
Arduino/libraries/SD/examples/ReadWrite/ReadWrite.pde

41 lines
703 B
Plaintext
Raw Normal View History

#include <SD.h>
File f;
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4.
if (!SD.begin(4)) {
Serial.println("failed!");
return;
}
Serial.println("done.");
f = SD.open("test.txt", true, false);
if (f) {
Serial.print("Writing to test.txt...");
f.println("testing 1, 2, 3.");
f.close();
Serial.println("done.");
} else {
Serial.println("error opening test.txt");
}
f = SD.open("test.txt");
if (f) {
Serial.println("test.txt:");
while (f.available()) Serial.write(f.read());
f.close();
} else {
Serial.println("error opening test.txt");
}
}
void loop()
{
}