Datasheet

view raw
char filename[15];
strcpy(filename, "ANALOG00.TXT");
for (uint8_t i = 0; i < 100; i++) {
filename[6] = '0' + i/10;
filename[7] = '0' + i%10;
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.print("Couldnt create ");
Serial.println(filename);
error(3);
}
Serial.print("Writing to ");
Serial.println(filename);
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
Serial.println("Ready!");
}
uint8_t i=0;
void loop() {
digitalWrite(8, HIGH);
logfile.print("A0 = "); logfile.println(analogRead(0));
Serial.print("A0 = "); Serial.println(analogRead(0));
digitalWrite(8, LOW);
delay(100);
}
adalogger.ino hosted with by GitHub
If you really want to make sure you save every data point, put a
logfile.flush();
right after the logfile.print's however this will cause the adalogger to draw a log more power, maybe about 3x as
much on average (30mA avg rather than about 10mA)
Next steps!
Once you know the SD card works, check out the SD card library (http://adafru.it/ucu) examples, SD library
documentation (http://adafru.it/ucu) and Notes (http://adafru.it/ucv)!
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-adalogger Page 41 of 47