TFT Touch Shield V2.0 How to init for SD data logging ?

I have entered the following sketch using information from the Version 2.0 wiki, the tftbmp sketch and, analog datalogger sketch. I am unable to initialize the SD card. The message returned is, “Card failed or not present”. The microSD has been erased and formatted to FAT-32 via OSX disk utility.



/*

SD card datalogger V2.0 TFT Touch Screen Version 2.0



*SPI bus is as follows

** MOSI - pin 11

** MISO - pin 12

** CLK - pin 13

** CS - pin 10 - must be high to enable SPI communications?


  • SD card attached to SPI bus as follows:?

    ** MOSI - pin 11

    ** MISO - pin 12

    ** CLK - pin 13

    ** CS - pin 4


  • TFT is attached to SPI bus as follows:?

    ** MOSI - pin 11

    ** MISO - pin 12

    ** CLK - pin 13

    ** CS - pin 5



    */



    #include <SD.h>

    #include <SPI.h>

    #include <TFTv2.h>



    Sd2Card card;

    SdVolume volume;

    SdFile root;



    // chip select constants

    const int spiSelect = 10; //SPI enable

    const int tftSelect = 5; //TFT enable

    const int sdSelect = 4; //SD enable



    void setup()

    {

    // Open serial communications and wait for port to open:

    Serial.begin(9600);

    while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only

    }



    pinMode(spiSelect, OUTPUT); // enable SPI chip

    digitalWrite(spiSelect,HIGH);

    SPI.begin();



    pinMode(tftSelect, OUTPUT); // disable TFT as I only wish to talk to SD Card

    digitalWrite(tftSelect,LOW);



    Serial.print(“Initializing SD card…”);

    // see if the card is present and can be initialized:

    card.init(SPI_FULL_SPEED, sdSelect);

    if (!SD.begin(sdSelect)) {

    Serial.println(“Card failed, or not present”);

    // don’t do anything more:

    return;

    }

    Serial.println(“card initialized.”);

    }



    void loop() {

    ;

    }

Hi There

maybe you need to determine the quality of SD Card by using TFT Touch Shield V2.0 example. :smiley: