Luckily many of the default examples already have chipSelect = 4 so you can just
upload immediately. For other sketches, do check to make sure that CS is set to 4!
The SD card uses hardware SPI for the remaining pins.
Anyhow, open up the serial console and you'll get all this info including a list of files
Once you have that working, check out the other examples, such the Datalogger
example (saving analog data to SD card) and Dumpfile example (reading back data
from an SD card)
Example logging sketch
If you want to try saving data to the SD card in the simplest sketch, try this example.
You can adjust the delay() to set how often analog data is read from pin A0 and saved
to the SD card. The red LED will blink if there's an error, and the green LED will blink
when data is written to the SD card.
Note that to save power, we buffer the data, so you will only 'save' data truely every
50 datapoints (512 total characters written)
1
2
#
include
<SPI.h>
#
include
<SD.h>
©Adafruit Industries
Page 36 of 39