My project has a remote unit that radio's data to the base unit, which then needs to save the data to an SD Card file.
When the remote unit turns on, the base needs to check to see if the file has already been opened, or if it needs to create a new file instead.
I'm concerned that the File variable might already have random data in it at startup, causing a boolean check to report the file open even when no file exists, unless I clear the File variable at startup. So how can I clear it?
File f = 0;
gives an error message, as does
File f= false;
File f = SD.open("");
But that makes f true! ... even though no file was created.
works, but what if there was junk in f already that close() ignored because it wasn't a real file, allowing f to remain true?
How can I safely clear f during startup to be sure it will read false until a file is actually opened?