Hi. I'm using the Adafruit Datalogging Shield with an Arduino Uno and an Adafruit 8GB SD/MicroSD card.
The SD card has been formatted using the official formatter from: https://www.sdcard.org/downloads/formatter_4/eula_mac/index.html
And the SD card reader I'm using is the port on my MacBook (I've read that this could be the problem).
I'm following Jeremy Blum's tutorial in Chapter 13 of Exploring Arduino and I'm using the following code in order to test that my SD card is working properly:
#include <SD.h>
//Set by default for the SD card library
//MOSI = pin 11
//MISO = pin 12
//SCLK = pin 13
//We always need to set the CS Pin
const int CS_PIN=10;
//We set this high to provide power
const int POW_PIN=8;
void setup() {
Serial.begin(9600);
Serial.println("Initializing Card");
//CS pin is an output
pinMode(CS_PIN, OUTPUT);
//Card will draw power from pin 8 so set it high
pinMode(POW_PIN, OUTPUT);
digitalWrite(POW_PIN, HIGH);
if(!SD.begin(CS_PIN))
{
Serial.println("Card Failure");
return;
}
Serial.println("Card Ready");
}
void loop()
{
long timeStamp = millis();
String dataString="Hello There!";
File dataFile = SD.open("log.csv", FILE_WRITE);
if(dataFile)
{
dataFile.print(timeStamp);
dataFile.print(",");
dataFile.println(dataString);
dataFile.close();
Serial.print(timeStamp);
Serial.print(",");
Serial.println(dataString);
}
else
{
Serial.println("Couldn't open log file");
}
delay(5000);
}
I keep getting "Card Failure". I've also tried the example code, CardInfo, from the SD library to no avail.
Any ideas why the card isn't opening?