I ran the code suggested in this forum topic and it works fine (returns SDHC FAT32 2897 MB), but I am still not able to write to an SD Card with Arduino Uno and a VMA304 shield. I am using the following simple test code, and all I get is messages saying “error opening datalog.txt”. Sometimes it will record once, but then it just gives the error forever. Also, when I open up the SD card on my PC after running this code all I see is gibberish and huge 3 MB files that I can’t open. I have formatted the card before running the code, but each time it creates these bogus files. Can you please help me resolve this issue? I have looked all over the web with no success.
#include <SPI.h>
#include <SD.h>
int chipSelect = 10;void setup() {
Serial.begin(9600);Serial.print(“Initializing SD card…”);
if (!SD.begin(chipSelect)) {
Serial.println(“Card failed, or not present”);
} else {
Serial.println(“Card initialized.”);
}Serial.println(“Starting”);
}void loop() {
String dataString = “data”;File dataFile = SD.open(“datalog.txt”, FILE_WRITE);
delay(2000);if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.print("Recording: ");
Serial.println(dataString);
} else {
Serial.println(“error opening datalog.txt”);
}delay(2000);
}