I bought an SD shield from Seeedstudio and can't seem to get it to work. Has anyone else had any success?
The code I'm using is from the Library link of Seeedstudio's page.
I did change the MEM_PW to 9 since that is the pin the shield powers from. I've tried at 8 as well, just in case.
All I get is "Fail initializing". Emailed Seeedstudio and they said to be sure and use an SD card that supports SPI, but I don't know how to tell if they do or not. I've tried 6 different ones so far from 1GB to 8GB in size, all formatted FAT, all failed.
If anyone can help me out I'd appreciate it!
//
// Title : FileLogger library for Arduino, example code
// Author : Eduardo García (egarcia@stream18.com)
// Date : April 2009
// Id : $Id: FileLoggerDemo.pde 24 2009-04-23 22:45:13Z stream18 $
//
// DISCLAIMER:
// The author is in no way responsible for any problems or damage caused by
// using this code. Use at your own risk.
//
// LICENSE:
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
#include "FileLogger.h"
// define the pin that powers up the SD card
#define MEM_PW 8
// variable used when reading from serial
byte inSerByte = 0;
#define MESSAGE "Hello, this is my message. Just testing the FileLogger library.\r\n"
unsigned long length = sizeof(MESSAGE)-1;
byte buffer[] = MESSAGE;
void setup(void) {
pinMode(MEM_PW, OUTPUT);
digitalWrite(MEM_PW, HIGH);
Serial.begin(9600);
}
void loop(void) {
char command = '0';
unsigned long t1, t2;
// Arduino expects one of a series of one-byte commands
if (Serial.available() > 0) {
int result;
inSerByte = Serial.read();
switch (inSerByte) {
case 'W':
result = FileLogger::append("data.log", buffer, length);
Serial.print(" Result: ");
if( result == 0) {
Serial.println("OK");
} else if( result == 1) {
Serial.println("Fail initializing");
} else if( result == 2) {
Serial.println("Fail appending");
}
break;
case 'T':
for(int i=0; i<10; i++) {
result = FileLogger::append("data.log", buffer, length);
Serial.print(" Result: ");
if( result == 0) {
Serial.println("OK");
} else if( result == 1) {
Serial.println("Fail initializing");
} else if( result == 2) {
Serial.println("Fail appending");
}
}
Serial.print("Done");
break;
}
}
}