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,you could download the libraries o our wiki, and open tmpbmo demo,like following code:

#include <SD.h>
#include <SPI.h>
#include “TFTv2.h”
File bmpFile;

unsigned char saved_spimode;
int bmpWidth, bmpHeight;
uint8_t bmpDepth, bmpImageoffset;

#define chipSelect 4

//set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

void setup()
{
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
TFT_CS_HIGH;
pinMode(chipSelect,OUTPUT);
digitalWrite(chipSelect,HIGH);

Serial.begin(38400);
SPI.begin();
Tft.TFTinit();
//SPI.setClockDivider(SPI_CLOCK_DIV4);
//SDcard_info();
/**/
DDRB |= 0x04;
card.init(SPI_FULL_SPEED,chipSelect);//SPI_QUARTER_SPEED SPI_HALF_SPEED, SPI_FULL_SPEED,
if(!SD.begin(chipSelect))//SPI_QUARTER_SPEED,
{ //53 is used as chip select pin
Serial.println(“failed!”);
while(1);
}
Serial.println(“SD OK!”);

Tft.setCol(0,239);
Tft.setPage(0,319);
Tft.sendCMD(0x2c);//start to write to display ram
TFT_BL_ON;
}

void loop()
{
/*
*/
char bmpfiles[][18]=
{
“flower.bmp”,“hibiscus.bmp”,“test.bmp”
};

Be careful of previous red lines, you need input your pictures’ name instead of “bmp1,bmp2,bmp3”

And i have not seen those codes that you have posted.

I am not attempting to show .bmp files.
I attempted to extract only that necessary to initialize the SDcard and make it available for reading and writing.
I have to do this without affecting the operation of the TFT Touch Screen.
I now have code that will initialize the SDcard, now to see if I can integrate it into the project without damage to the project, which is a satellite tracking utility.

Thank you for your reply. It was helpful.