Ethernet Shield -> SD Card on an Arduino Mega 2560

Hello,

I am trying to move my current project from a arduino DUE to a arduino MEGA...

Everything seemed to work fine till it came to the SD card...

This is an code example that worked with the DUE...

const int chipSelect = 4;
const int sdCardCheckRed = 51;
const int sdCardCheckGreen = 41;

void setup() {
  pinMode(10, OUTPUT);
}

void MyInitSDCard() {
  if (!SD.begin(chipSelect)) {
    setup();
  }
  else {

    digitalWrite(sdCardCheckRed, LOW);
    digitalWrite(sdCardCheckGreen, HIGH);
  }
  if (SD.exists("pc.txt")) {
    SD.remove("pc.txt");
  }
}

However I found that a lot of people having the same issue as I have - I have not found a dedicated tutorial that describes how to solve the issue...

Do I need to physically wire pin 50, 51, 52, 53 to 11, 12, 13, 10?

Di I need to exchange the SD Card library?

What else is to do to make this work again?

Kind Regards,

Andreas

No need to jumper pins. Just plug it in.

Try this simple sketch. Does it start the SD card ok?

#include <SD.h>

void setup() {
  Serial.begin(9600);

  // disable w5100 SPI
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  Serial.print(F("Starting SD.."));
  if(!SD.begin(4))  Serial.println(F("failed"));
  else Serial.println(F("ok"));
}

void loop() {
}

THX, that worked perfectly! :-)