Pages: [1]   Go Down
Author Topic: problem with leonardo & sd card!!!!! help me  (Read 865 times)
0 Members and 1 Guest are viewing this topic.
egypt
Offline Offline
Newbie
*
Karma: 0
Posts: 29
i 'm biomedical engineer and love arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

help me !!!!!!!!!!!!
the SD card doesn't work with Leonardo kit but work with UNO kit !!
i use this code
Code:
/*
  SD card test
   
 
#include <SD.h>

Sd2Card card;
SdVolume volume;
SdFile root;


const int chipSelect = 4;   

void setup()
{
 
  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(10, 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) {
 
}
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6007
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Leonardo is a bit different than the Uno. The SPI data lines are not on any digital pins. They are only on the ICSP pins. This is from the Leonardo datasheet:
Quote
SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work.
Logged

egypt
Offline Offline
Newbie
*
Karma: 0
Posts: 29
i 'm biomedical engineer and love arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

what!!!!! smiley-cry smiley-cry smiley-cry smiley-cry smiley-cry smiley-cry smiley-cry
but i need work it with RFID reader
what i can do????!
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6007
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't panic! Are these shields or a separate circuit board?

Logged

egypt
Offline Offline
Newbie
*
Karma: 0
Posts: 29
i 'm biomedical engineer and love arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes , i need to connect NFC/RFID shield V1.0
with SD card
what i can do???
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6007
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That depends on you. If you are willing to experiment, and "pin bend" a little, you could probably get the shield working. What you will need to do is jumper the ICSP pins to D11-D13 so it will be Uno compatible. Are you willing to try that?

Don't panic...and don't forget your towel!  smiley
Logged

egypt
Offline Offline
Newbie
*
Karma: 0
Posts: 29
i 'm biomedical engineer and love arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes i will try but tell me the details plllzzz  smiley-draw
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 146
Posts: 6007
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a pic of the Leonardo here:
http://arduino.cc/en/Main/ArduinoBoardLeonardo

You can see the ICSP connector there. The upper left pin is pin 1, and on the left side is pin 3 and pin 5 below it. The upper right pin is pin 2 and below it is pin 4 and pin 6.

Pin 1 is MISO -> D12 on shield
Pin 3 is SCK -> D13 on shield
Pin 4 is MOSI -> D11 on shield

Here is the schematic. ICSP is in the upper left corner.
http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf

I won't accept any responsibility for experiments. It is an "implied risk" deal.
Logged

Pages: [1]   Go Up
Jump to: