#include <SPI.h>
#include <SD.h>
#define CS_PIN 13
#define MISO_PIN 19
#define SCK_PIN 18
#define MOSI_PIN 13
File root;
void setup(){
Serial.begin(9600);
SPI.begin(SCK_PIN, MISO_PIN, MOSI_PIN, CS_PIN);
SD.begin(CS_PIN);
//root = SD.open("/");
File myFile = SD.open("test.txt", FILE_WRITE);
if(!SD.begin(CS_PIN)){
Serial.println("initialization failed!");
}
else {}
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
myFile.println("testing 1, 2, 3.");
}
void loop(){
}