Hardware Reference
In-Depth Information
WritingtoanSDCard
First, you use the SD card library to write some sample data to your SD card.
Later in the chapter, you capture some sensor data and write that directly to the
SD card. The data is stored in a file called log.csv that you can later open up on
your computer. Importantly, if you formatted your card FAT16, the filenames
you use must be in 8.3 format. This means that the extension must be three
characters, and the filename must be eight characters or fewer.
Ensure that your SD shield is mounted correctly to your Arduino and that
you have an SD card inserted. When mounted, the Cooking Hacks SD shield
looks like FigureĀ 13-13. (The pins are inserted into pins 8-13, and the jumper is
on the right side when viewed from this angle.)
Figure 13-13: Mounted SD card shield
For the sake of debugging, you will take advantage of the reporting functional-
ity of many of the SD card functions. For example, to initialize communication
with an SD card, you call the following function in your setup:
if (!SD.begin(CS_pin))
{
Serial.println("Card Failure");
Search WWH ::




Custom Search