Hello, I’m new to Arduino and I need your help if possible. Thank you
I have just developed a datalogger to detect door openings and record them on a .CSV file (data.csv) in a micro sd card.
I use a micro sd module and a magnetic door opening sensor.
If possible, I would like to create a new data.csv file each time I restart the arduino.
Have a new file for each time I restart the arduino.
Example: :
data1.csv
data2.csv
data3.csv
.
.
.
datan.csv
Here’s the code:
// SSD Lib
#include <SPI.h>
#include <SD.h>
#define CS_PIN 10
File myFile;
int compt = 0;
void setup() {
var = 0;
while(SD.exists(data(compt))){
compt = compt+1; //
}
Serial.print("SD card initialization in progress...");
if (!SD.begin()) {
Serial.println("SD card initialization failed!");
return;
}
Serial.println("The initialization of the SD card was successful!");
myFile= SD.open("data(compt).csv", FILE_WRITE);
if (myFile) {
myFile.println("Open,Time Open,Time Close,Time,Cumulative Time,%");
myFile.close();
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Thank you very much for helping me