Besoin d'aide pour lecteur carte SD du module TFT touchscreen SY-TFT240 V1.1

Bonjour,

L’écran fonctionne, mais je n'arrive pas à faire fonctionner le lecteur de carte SD de mon module LCD TFT touchscreen SY-TFT240 V1.1. Il est relié à une arduino mega 2560.

Là je désespère. J'ai besoin d'aide.

Comme on peut le voir sur cette photo : http://i1.wp.com/tronixstuff.com/wp-content/uploads/2013/04/frontback.jpg

il y a 4 pin sur l'écran pour le lecteur SD (MOSI, SCK, MISO et CS)

J'ai connecté comme suis à la carte arduino mega 2560 :

pin 50 : MOSI
pin 51 : MISO
pin 52 : SCK
pin 53 : CS

Et ça marche pas. Par ailleurs, je ne sais pas si mon problème vient du cablage ou du code.

J'utilise l'exemple cardinfo.ino

Je remplace const int chipSelect = 4; par const int chipSelect = 53;

Ce qui donne au final :

#include <SPI.h>
#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 = 53; *
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*

  • }*

  • 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(SS, OUTPUT);*

  • // we'll use the initialization code from the utility libraries*

  • // since we're just testing if the card is working!*

  • while (!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?");_

  • }*

  • // 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) {

}

Quelqu'un voit ce qui ne va pas?

Merci d'avance pour votre aide

bonjour,
code entre balise code </>

Broches 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS)

Bonjour,

Merci

Finalement j'ai réussi à le faire marcher avec la broche 53 sur CS et 52 sur CLK. Mais le fonctionnement est très aléatoire. Il faut enlever et remettre la carte SD pour que ça le detecte et ça marche pas à coup sûr. Et là j'ai un autre problème. L'écran reste blanc maintenant. Impossible de le refaire fonctionner en televersant le programme qui marchait précédemment.

Hello

si tu as câblé MISO et MOSI comme tu le dis au départ de ton post..................c'est inversé