Datasheet

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)
#include <SPI.h>
#include <SD.h>
// Set the pins used
#define cardSelect 4
File logfile;
// blink out an error code
void error(uint8_t errno) {
while(1) {
uint8_t i;
for (i=0; i<errno; i++) {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
for (i=errno; i<10; i++) {
delay(200);
}
}
}
// This line is not needed if you have Adafruit SAMD board package 1.6.2+
// #define Serial SerialUSB
void setup() {
// connect at 115200 so we can read the GPS fast enough and echo without dropping
chars
// also spit it out
Serial.begin(115200);
Serial.println("\r\nAnalog logger test");
pinMode(13, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(cardSelect)) {
Serial.println("Card init. failed!");
error(2);
}
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-adalogger Page 40 of 47