now here is my software (using Arduino 0022)
this program works (writes increment number up to 5000 to the SD card) but if I uncomment all the Serial.print() instructions the program just writes the fyrst Serial.print("Initializing SD card...") to the Serial monitor and freezes, or keeeps just writing "Initializing SD card" forever.
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
updated 2 Dec 2010
by Tom Igoe
This example code is in the public domain.
*/
#include <SD.h>
File file;
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
Serial.begin(9600);
// Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
// Serial.println("initialization failed!");
// return;
}
// Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
}
int j;
void loop()
{
j++;
file = SD.open("Test.txt", O_CREAT | O_WRITE | O_APPEND);
while(millis() < 1000); // delay so mills() is four digits
for (int i = 0; i < 5000; i++) {
file.println(i);
//Serial.println(i);
}
// not needed in this example since close() will call flush.
file.println(j);
file.flush();
file.close();
}