Hardware Reference
In-Depth Information
short for Long File Names, but it is only an extension; it is not part of the FAT
specii cation. There is a reason why your camera names your photos IMG_xxxx.
JPG; it is probably limited to the 8.3 i le-naming system. Arduinos also can
use only 8.3 i lenames. This isn't a problem for cameras where i lenames are
just numbers, and it is rarely a problem for Arduinos where i les are normally
coni guration, or data-logging.
Communications to and from the SD card are done via SPI. The SS pin (SPI
Slave Select) must be left untouched. The SD library will not work if the SS pin
is not coni gured as an output.
Numerous shields exist and do not always use the same pin to initialize the
SD card. The chip select pin can change from one design to another; consult
the shield documentation to know which pin to use when initializing the SD
card reader.
The SD Library
The Arduino language has an SD library built in. This library depends on three
other internal libraries that handle card and i lesystem-specii c functions, but
abstraction makes the library extremely easy to use. It is possible to use the other
libraries, which is explained briel y in the “Advanced Usage” section.
Importing the Library
To be able to use the SD library, you must i rst import it. This can be done either
automatically in the Arduino IDE by going to the Sketch
Import Library
SD menu item, or manually with this:
#include <SD.h>
Arduinos communicate with SD card controllers using the SPI protocol. Thus,
you must also import that library:
#include <SPI.h>
Connecting a Card
As with many Arduino libraries, to initialize the library, you must call SD . begin() .
result = SD.begin();
result = SD.begin(csPin);
SD.begin() returns true if a card is detected and the library initialized;
otherwise, it returns false . The optional csPin argument is used to coni gure
 
Search WWH ::




Custom Search