fat16lib:
This should not be required for the SparkFun shield unless you have a second SPI device.Please run this program to get more info.
#include <SD.h>
#include <SPI.h>
Sd2Card card;
SdVolume vol;
SdFile root;
// Chip select pin for SD card.
const int sdCsPin = 8;
// Replace the -1 with the CS pin number of any shared SPI device.
const int sharedCsPin = -1;
void setup() {
Serial.begin(9600);
// Disable any other SPI devices
if (sharedCsPin >= 0) {
pinMode(sharedCsPin, OUTPUT);
digitalWrite(sharedCsPin, HIGH);
}
// Try to initialize the SD card
if (card.init(SPI_HALF_SPEED, sdCsPin)) {
Serial.println("card init OK");
} else {
Serial.print("errorCode: ");
Serial.println(card.errorCode(), HEX);
Serial.print("errorData: ");
Serial.println(card.errorData(), HEX);
return;
}
// Try to initialize the FAT volume.
if (vol.init(&card)) {
Serial.println("vol init OK");
} else {
Serial.println("vol init failed");
return;
}
// Try to open root
if (root.openRoot(&vol)) {
Serial.println("open root OK");
} else {
Serial.println("open root failed");
}
}
void loop() {}
If all is well you should see this: If there is a hardware problem with the shield or card you will see something like this: If the card format is bad you will see something like this: Or this: Please post the results.
hi sir.. i tried your code.. got error message as below, what does it mean??? pls help to solve it..
errorCode: 8
errorData: 5
thanks in advance...