"OK! I thought it was something like that! At this point, since the function that writes the file is always executed after reading the file, and reading the file only occurs when Arduino is powered on, I could modify the function in this way:"
void salva_datalog() {
Serial.println("Apertura del file...");
FILE *f = fopen("/usb/datalog.txt", "w+");
if (!f) {
Serial.println("Errore nell'apertura del file.");
return; // Esci dalla funzione se c'è un errore
}
// Scrivi i dati nel file
for (int i = 0; i <= 11; i++) {
fprintf(f, "%d\n", Totale_scatti[i]);
}
// Chiudi il file
fclose(f);
Serial.println("File data_log chiuso.");
}
this is because the drive is already connected and i dont need to connect it again !
Tnx u!