Go Down

Topic: Trying to get SD to initialize. (Read 465 times) previous topic - next topic

Bugman1400

I am just trying to make contact with my SD card. It is a 16GB that was formatted with SD Card Formatter and then inserted into an Ethernet2 w/ W5500 shield. The Serial Window just shows "SD card initialization failed" every time.

I use the following sketch....

Code: [Select]
/*
     *  Arduino SD Card Tutorial Example
     * 
     *  by Dejan Nedelkovski, www.HowToMechatronics.com
     */
    #include <SD.h>
    #include <SPI.h>
   
    File myFile;
    int pinCS = 4; // Pin 10 on Arduino Uno
    void setup() {
       
      Serial.begin(9600);
      pinMode(pinCS, OUTPUT);
     
      // SD Card Initialization
      if (SD.begin())
      {
        Serial.println("SD card is ready to use.");
      } else
      {
        Serial.println("SD card initialization failed");
        return;
      }
     
      // Create/Open file
      myFile = SD.open("test.txt", FILE_WRITE);
     
      // if the file opened okay, write to it:
      if (myFile) {
        Serial.println("Writing to file...");
        // Write to file
        myFile.println("Testing text 1, 2 ,3...");
        myFile.close(); // close the file
        Serial.println("Done.");
      }
      // if the file didn't open, print an error:
      else {
        Serial.println("error opening test.txt");
      }
      // Reading the file
      myFile = SD.open("test.txt");
      if (myFile) {
        Serial.println("Read:");
        // Reading the whole file
        while (myFile.available()) {
          Serial.write(myFile.read());
       }
        myFile.close();
      }
      else {
        Serial.println("error opening test.txt");
      }
     
    }
    void loop() {
      // empty
    }

obelix20

I have the same problem. I changed my memory card from SDHC 16GB into a 2GB card and it works well

Go Up