Skip to content

Instantly share code, notes, and snippets.

@Tech500
Last active September 4, 2022 17:04
/*
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