Hardware Reference
In-Depth Information
{
Serial.println("Couldn't open log file");
}
delay(5000);
}
You want to note a few important things here, especially if you are not using
the same Cooking Hacks MicroSD card shield:
CS_PIN should be set to whatever pin you have your SD card CS hooked
up to. If it is not 10, you must also add pinMode(10, OUTPUT) within
setup() ; otherwise, the SD library will not work.
This particular shield draws power from pin 8 (as opposed to being con-
nected directly to a 5V supply). Therefore, POW_PIN must be set as an
output and set HIGH in the setup function to power up the SD card shield.
Each time through the loop, the timestamp variable is updated with the
current time elapsed in milliseconds. It must be of type long because it
will generate a number larger than 16 bits (the standard size of an Arduino
integer type).
As you saw earlier, the filename is opened for writing and data is appended
in a comma-separated format. The same data is also printed out to the serial
terminal for debugging purposes. This is not explicitly necessary, and you will
not use it once you have the logger “in the field” taking data. However, it is use-
ful for confirming that everything is working. If you open the serial terminal,
you should see something like Figure 13-14.
Figure 13-14: SD Card debugging output
Search WWH ::




Custom Search