I've got a sketch that isn't writing to the SD card at all. It will create a file on the card, but not write to it.
It's an eBay special SD Card (3X SD Card Interface Module Slot Socket Adapter Reader SPI Arduino Arm Pi USA | eBay), but otherwise works with the SD Library. I can list files on the card. It will give me info about the card. It just won't write to it.
I even tried the data logger, and it will create the file, but not write. Datalogger gives the "error opening datalog.txt" over and over again, even though the file is there, and was created on the card by the first run through.
Anyway, to simplify things, I wrote this barebones sketch:
#include <SD.h>
File myFile;
boolean SDOK=false;
void setup(){
pinMode(10,OUTPUT);
Serial.begin(57600);
SDOK=SD.begin();
if (SDOK){
Serial.println("init OK");
myFile=SD.open("TEST.TXT",FILE_WRITE);
if (myFile){
Serial.println("file OPEN");
myFile.println("LINE ONE");
Serial.println("prtn ONE");
myFile.write("LINE TWO");
Serial.println("wrte TWO");
myFile.flush();
myFile.close();
} else {
Serial.println("file FAIL");
}
} else {
Serial.println("init FAIL");
}
}
void loop(){
}
It will show the following output:
init OK
file OPEN
prtn ONE
wrte TWO
I'm not sure what I'm doing wrong. I know the flush isn't necessary in there, but since it's not writing, I figured I'd throw it in there.
Any help you guys could give me would be greatly appreciated.
Thanks!