I am trying to load some variables from an SD card on the start up of my arduino Uno. I have been given some advice but am unable to communicate at the same hours. Using this advice, I have the following edited code, but it doesn't work and I believe that it's my implementation that is the problem. All help would be greatly appreciated.
myFile = SD.open("test.txt", FILE_READ);
if (myFile) {
while (myFile.available()) {
myFile.read();
km = myFile.parseInt();
kmTemp = myFile.parseFloat();
kmrevs = myFile.parseInt();
miles = myFile.parseInt();
milesTemp = myFile.parseFloat();
milesrevs = myFile.parseInt();
}
myFile.close();
}
else {
Serial.println("Read Error");
}
1 Answer 1
in you previous question, where I answered, you had no commas or new-lines in the example file content. the parseInt and parseFloat ignores only spaces by default.
remove the commas or read them or ignore them with parseInt parameter SKIP_ALL
km = myFile.parseInt(SKIP_ALL);
-
Hi there is no commas, it's just in the comments section, whenever I press enter it posts the message instead of starts a new line....so I used commas to seperate the different data.user4163554– user41635542018年05月06日 21:47:40 +00:00Commented May 6, 2018 at 21:47
-
Hi Juraj. I have to admit, I have never analysed anything as much as your two answers. I feel that my bank holiday was no longer wasted as I have finally worked out what you meant. All is rolling amazingly now and it's just what I wanted. Thank you.user4163554– user41635542018年05月08日 10:14:15 +00:00Commented May 8, 2018 at 10:14
Explore related questions
See similar questions with these tags.
what is actually written in the file you want to read?
please answer this question.