// On the Ethernet Shield, CS is pin 4. Note that even if it's not// used as the CS pin, the hardware CS pin (10 on most Arduino boards,// 53 on the Mega) must be left as an output or the SD library// functions will not work.

Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to // output, even if you don't use it: pinMode(10, OUTPUT); digitalWrite(10, HIGH); pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH);

// see if the card is present and can be initialized: if (!SD.begin(SD_CS)) { 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 = "";