Micro SD not working

I have a program that was working with the SD card data logging. I had to change around some gps info and when and where it was reading the gps. I turned the gps into a function. After doing this, the SD card does not initialize any more. I am at a loss.

I am using the Mega board, a k30 co2 sensor and a weather with gps shield from sparkfun.

The two programs are attached v3 works, v4 does not.

Any help would be appreciated

Benthic_Chamber_CO2_Weather_v3.ino (37.3 KB)

Benthic_Chamber_CO2_Weather_v4.ino (39.3 KB)

I had been trying to write to the SD card in the gps function. I commented althat part out and returned the data logging to the main loop. The card is now logging and all is right with the world! :P However I do not understand why having the data logging in a function would cause the problem. Does anyone have an answer for that?

I had been trying to write to the SD card in the gps function.

I looked in your second code for theGpsFunction(), but I didn’t see it.

I gave up on trying to read the code when it appears as though every } was in column 1.

Use Tools + Auto Format BEFORE posting code.