Hello,
I am having an issue when attempting to use a SD card breakout board to write a file to an SD Card. My output is stating that there is no card or an issue with the card. I can read the card on my OS just fine. I have even downloaded the SD Formatter program, as I read that formatting with the OS can be an issue.
I am relatively new to electronics/Arduino (but I am a web application programmer if that helps).
This is the SD Card breakout board that I am using:
http://www.jaycar.com.au/medias/sys_master/images/8895839895582/XC4598-dataSheetMain.pdf
These are the specifications:
http://linksprite.com/wiki/index.php5?title=SD_Card_Breakout_Board
I have double checked my wiring, and all appears correct. Below is my code:
/*
* * SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK(SCK) - pin 13
** CS(SS) - pin 4
*
*/
#include <SD.h>
#include <SPI.h>
//Select PIN 4 as the chip select PIN
const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.print("Initializing SD card...");
//Set PIN 4 to be an ourput PIN
pinMode(chipSelect, OUTPUT);
digitalWrite(chipSelect, HIGH);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect))
{
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
}
void loop()
{
// make a string for assembling the data to log:
String dataString = "Test 1, 2, 3\r\n";
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// if the file is available, write to it:
if (dataFile)
{
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
// if the file isn't open, pop up an error:
else
{
Serial.println("error opening datalog.txt");
}
}
This is the output that I am getting in my serial monitor:
Initializing SD card...Card failed, or not present
error opening datalog.txt
error opening datalog.txt
error opening datalog.txt
At this point, I am not sure what is causing the error. Any suggestions/help is much appreciated.
Thanks.