Skip to content

Instantly share code, notes, and snippets.

@Tech500
Last active September 4, 2022 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tech500/f52973764b0ae4c16c9ec64a9dcf6619 to your computer and use it in GitHub Desktop.
Save Tech500/f52973764b0ae4c16c9ec64a9dcf6619 to your computer and use it in GitHub Desktop.
/*
Fuction to read all lines of a text file line by line; then on selected an array element print
the selected array elemment. Coding help from Pauljujo of Random Nerd Tutorials Lab Forum.
09/04/2022 Code by Pauljujo and William Lucid
void readWord(){
// Open a "wordfile.txt" for reading
File word = LittleFS.open("/wordfile.txt", "r"); //input words from "wordfile.txt"
if (! word){
Serial.println("File 'wordfile.txt' open failed");
}
while(word.available()) {
for (list_Word = 0; list_Word < 10; list_Word++) {
inputWord[list_Word] = word.readStringUntil('\n'); //Read line until newline
Serial.println(inputWord[list_Word]);
}
}
word.close();
Serial.println("");
Serial.println(inputWord[3]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment