Datalogger and 2 Accelerometers

So this is my second post in this forum. At first I was asking about being able to use I2C and SPI protocols simultaneously and was told that it was possible. Now the problem is that i got the 2 accelerometers to work together (both I2C) and i am able to initialise the SD card, but when i try to open a file and write, the program just freezes. This is the part of the code having to do with the SD card:

//Initialize Card in void setup()
if (!SD.begin(CS_pin))
{
Serial.println("Card Failure");
return;
}
Serial.println("Card Ready");

//Open file in void loop() after filtering the 6 values for the acc. and then outputting them to serial
int output1=movingAvarageFilter.process(acc_Front.value.x);
int output2=movingAvarageFilter1.process(acc_Front.value.y);
int output3=movingAvarageFilter2.process(acc_Front.value.z);
int output4=movingAvarageFilter3.process(acc_Rear.value.x);
int output5=movingAvarageFilter4.process(acc_Rear.value.y);
int output6=movingAvarageFilter5.process(acc_Rear.value.z);

Serial.print(output1); Serial.print(",");
Serial.print(output2); Serial.print(",");
Serial.print(output3); Serial.print(",");
Serial.print(output4); Serial.print(",");
Serial.print(output5); Serial.print(",");
Serial.println(output6);

File logFile = SD.open("LOG.csv", FILE_WRITE);
if (logFile)
{
logFile.println("Hello");

logFile.close();
}
else
{
Serial.println("Couldn't open log file");
}

Maybe you are running out of SRAM? Which Arduino model are you using? The SD.open() function requires a bit of SRAM (500 bytes).

You might want to try using the F() function to keep the strings in program memory. That may help.

//Initialize Card in void setup()
  if (!SD.begin(CS_pin))
  {
      Serial.println(F("Card Failure"));
      return;
  }
  Serial.println(F("Card Ready"));

I'm using a Duemilanove clone board. Tomorrow my Leonardo should be arriving in the post so maybe if i try it on it, it'll work. But for now i'll try using the F() function. Thanks man

IT WORKED!!! Thanks a lot :smiley: