Hello!
Thanks for replies.
Lets me explain more detailed.
First of all Arduino - Duemilanove, 328
I'm using SD.h for communicated with SD card.
Wiring is:
CS - 4
MOSI - 11
CSK - 13
MISO - 12
SD card is formatted in vfat (msdos fat) Any other format doesn't allow to initialize card.
Results is:
1.
Serial.begin(9600);
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
...
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");
}
works fine. I could save a file to SD card on my linux laptop and read it in Serial console.
2.
....
myFile = SD.open("test.txt", O_CREAT | O_WRITE | O_APPEND);
// if the file opened okay, write to it:
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");
}
....
Doesn't work.
I need reformat card after this execution.
If you have any suggestions - please help.
I'm new in Arduino world.