not sure if this goes in Programming, but i doubt it's a bug with the Arduino board so i didn't want to put it there.
it's more likely bad coding, but i did follow the code from here;
here's the code as i actually used it;
/*
This example shows how to log data
to an SD card using the SD library.
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 10
created 24 Nov 2010
modified 9 Apr 2012 by Tom Igoe
This example code is in the public domain.
*/
#include <SD.h>
const int chipSelect = 10;
File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing a, b, c.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
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");
}
}
void loop()
{
// nothing happens after setup
}
the problem is the text is saved twice to the file.
i then discovered it's saved again if i close the Serial monitor and open it again.
is this a normal condition, and something that has to be accepted while debugging code ?