Creating A Lot Of Files On An SD Card With An Arduino. Code Complies ...

Skip to content Search Gists Search Gists All gists Back to GitHub Sign in Sign up Sign in Sign up Dismiss alert {{ message }}

Instantly share code, notes, and snippets.

@carlynorama carlynorama/generateFilesOnSDcard.ino Last active November 2, 2022 13:33 Show Gist options
  • Star (5) You must be signed in to star a gist
  • Fork (0) You must be signed in to fork a gist
  • Embed Select an option
    • Embed Embed this gist in your website.
    • Share Copy sharable link for this gist.
    • Clone via HTTPS Clone using the web URL.

    No results found

    Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/carlynorama/9300525.js"></script>
  • Save carlynorama/9300525 to your computer and use it in GitHub Desktop.
Code Revisions 3 Stars 5 Embed Select an option
  • Embed Embed this gist in your website.
  • Share Copy sharable link for this gist.
  • Clone via HTTPS Clone using the web URL.

No results found

Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/carlynorama/9300525.js"></script> Save carlynorama/9300525 to your computer and use it in GitHub Desktop. Download ZIP Creating a lot of files on an SD Card with an Arduino. Code complies. Keeping it as a reminder of how to work with String to char array conversion Raw generateFilesOnSDcard.ino This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
void generateFiles() {
//derived from code found at http://forum.arduino.cc/index.php?topic=57460.0
String fileName = String();
String message = String();
unsigned int filenumber = 1;
while(!filenumber==0) {
fileName = "file_";
fileName += filenumber;
fileName += ".txt";
message = fileName;
char charFileName[fileName.length() + 1];
fileName.toCharArray(charFileName, sizeof(charFileName));
if (SD.exists(charFileName)) {
message += " exists.";
filenumber++;
}
else {
File dataFile = SD.open(charFileName, FILE_WRITE);
message += " created.";
dataFile.close();
filenumber = 0;
}
Serial.println(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.

Tag » Arduino Sd.open Variable Filename