I have a simple code that can open an SD card, write data to it, then close the SD card.
But what I want to achieve is to open the SD card early on, then do a for loop for 50 samples writing 50 bits of data, then close the SD card once all the samples have been written.
I gave this a go but when I separate the open/write/close operations it returns an error saying 'logFile' not declared in this scope. Any help?
This is the simple code to open/write/close the SD card, but i want to separate the open and close operations from the write.
File logFile = SD.open("TEST12.csv", FILE_WRITE); logFile.print(dataString); logFile.print(time); logFile.print(", "); logFile.print(a); logFile.print(", "); logFile.println(x); logFile.close();
Is there a different syntax for writing to an open file? I don't see how the code should vary from above. Sorry for the noobie question, thanks for any help!