Datasheet

Now we'll grab the new SD library, visit https://github.com/adafruit/SD (http://adafru.it/aP6)
and click theZIP download button, or click the button below
Download the SD Library Zip
http://adafru.it/cxl
Uncompress and rename the uncompressed folder SD. Check that the SD folder contains
SD.cpp and SD.h
Place the SD library folder your sketchbook libraries folder. You may need to create the
libraries subfolder if its your first library. For more details on how to install libraries, check out
our ultra-detailed tutorial at (http://adafru.it/aYM)http://learn.adafruit.com/adafruit-all-about-
arduino-libraries-install-use (http://adafru.it/aYM)
Using the SD Library with the Mega and Leonardo
Because the Mega and Leonardo do not have the same hardware SPI pinout, you need to
specify which pins you will be using for SPI communication with the card. For the data logger
shield, these will be pins 10, 11, 12 and 13. Find the location in your sketch where SD.begin()
is called (like this):
and change it to add these pin numbers as follows:
cardinfo
The cardinfo sketch uses a lower level library to talk directly to the card, so it calls card.init()
instead of SD.begin().
When calling card.init(), you must change the call to specify the SPI pins, as follows:
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
// see if the card is present and can be initialized:
if (!SD.begin(10, 11, 12, 13)) {
// 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)) {
© Adafruit Industries https://learn.adafruit.com/adafruit-data-logger-shield Page 31 of 68