3.2" TFT LCD Shield + Display w SD Socket for Arduino Mega 2560, SD Problem

No, i did the same, not working yet.

I'm using a Mega2560 with an ethernet shield to test. I bent D4 on the shield so the SD slave select would not connect there, then jumpered that to D49. That hardware setup works fine.

Are you certain the SPI lines are connected from the TFT to the Mega correctly? That would be the difference. I use the ICSP connector for the SPI data lines, not pins 50-52.

I'm using the shield, I tried the jump but it did not worked, I have an Ethernet shield as well and the SD card works, but I need to use the SD Card in the LCD, because I’m not using the Ethernet shield in this project. i think that maybe is something in the software that i must change, but i don't now what.

Thanks

Are you certain the SPI data lines are connected correctly from the TFT to the Mega?
MISO -> 50
MOSI -> 51
SCK -> 52

Yes, i checked over here, the lines are correct.

I took a look at the hardware on the TFT, and I see no logic converters for the inputs to the SD like on the ethernet shield. Otherwise, I'm not sure what is happening.

Yes, but I dont think they would do the place to put de SD CARD and everthing else if not to let it working, thats why i think the change i need to do is on the Software... but i'm not sure.

question, what is your chipselect at, 53 or 4.
Make it 4 and change pinMode(10, output) to 53 AND DONT MAKE IT LOW OR HIGH,
digitalWrite(53,LOW or HIGH) take this out of your code.

if all else fails, either update your software or downgrade it, it might just be a bug somewhere in the SD.h file.

HazardsMind:
question, what is your chipselect at, 53 or 4.
Make it 4 and change pinMode(10, output) to 53 AND DONT MAKE IT LOW OR HIGH,
digitalWrite(53,LOW or HIGH) take this out of your code.

if all else fails, either update your software or downgrade it, it might just be a bug somewhere in the SD.h file.

No i update to version 1.0.2, and the problem persists, i made the SD chip select 4, and yet nothing, what else can this be?

Thanks

When you bought the TFT did it come with any websites you can go to, custom libraries, examples, anything at all?

You may need to contact the seller and ask if he/ she knows where to get the correct code that works for that shield.

Quick question, there should be a little switch on the I/O shield, is that set to 5V or 3.3V, because according to the hardware page you provided, it says to have it set to 5V to work for the ARD mega 2560.

also your CS should be set to 53, my mistake.

Yes, but even when i put

 pinMode(53, OUTPUT);
   
  if (!SD.begin(53)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

It's not working, but i realized something in the library says

  • SD card attached to SPI bus as follows:
    ** MOSI - pin 11
    ** MISO - pin 12
    ** CLK - pin 13
    ** CS - pin 4

But in my case the pins are:

MOSI:51
MISO:50
CLK:52
CS:53

Do i have the change this? How do i change this?

Thanks

The code you posted the first time did you alter that or is that the actual code that was given to you?

here try this.

/*
  SD card test 
   
 This example shows how use the utility libraries on which the'
 SD library is based in order to get info about your SD card.
 Very useful for testing a card when you're not sure whether its working or not.
 	
 The circuit:
  * SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module. 
 		Pin 4 used here for consistency with other Arduino examples

 
 created  28 Mar 2011
 by Limor Fried 
 modified 16 Mar 2011
 by Tom Igoe
 */
 // include the SD library:
#include <SD.h>

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

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4; // if 4 dont work try 10, else try 8, NOT 53    

void setup()
{
  Serial.begin(9600);
  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(53, OUTPUT);     // change this to 53 on a mega


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }


  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
  
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

  
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {
  
}

That the code given to me, i tried all the pins, 4 , 10 and 8, even 53 but none worked, i still thinking that maybe there is something to do in the MOSI, CLK and MIMO pins.

Thanks.

what is your baud rate?, Serial.begin(???)

Last thing, did the code you get come in a folder with other files in it? Im looking for something .h and .CPP.
if it did not then I can no longer help you, I have done everything I can think of.

ok, thanks for this, i'm using the arduino SD example: WriteRead, i'm Attaching all the library whithin the examples in it.

Thanks a lot.

SD.rar (54.1 KB)

The problem more than likely is that it is a 1.0 sainsmart variant ~ equivalent shield. The wiring to the cs meso and mosi pins is wrong on the shield. The good news is that if you can solder it is fixable by removing 4 resistors and "flying" four wires on the shield to make the correct connections. instructions that are pretty good are here, SainSmart | Desktop CNC, 3D Printing & DIY Tools | Power to the Makers – SainSmart.com.
Then set the cs pin to 53. and it will work with the sd library just fine. the other pins are called by spi internally and are always the same depending on which duino you have.