forked from bborncr/datalogger-m0-feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNEW.ino
More file actions
25 lines (23 loc) · 642 Bytes
/
Copy pathNEW.ino
File metadata and controls
25 lines (23 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
bool initSDCard() { //inits SD Card, open new file and inserts header
bool success = false;
if (!SD.begin(CS)) {
success = false;
} else {
char filename[15];
strcpy(filename, "LOG00.TXT");
for (uint8_t i = 0; i < 100; i++) {
filename[3] = '0' + i / 10;
filename[4] = '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);
//Create header
logfile.println("time,accelX,accelY,accelZ");
logfile.flush();
success = true;
}
return success;
}