Go Down

Topic: How to arduino import var values from text files!! (Read 2860 times) previous topic - next topic

happyboy

Hello

sorry for my poor English,

How to arduino import var values from text files to read from sd card!
My text file is:
var.txt
myvar1 = 120
myvar2 = 10
myvar3 = 60
....
....

PaulS

Which library are you using to store data on the SD card? Some libraries make it easier to read from the SD card than others.

Depending on how the data is retrieved from the SD card, different methods are available to parse the data.

For data in char arrays, strtok can be used to parse the records, into tokens. If an array contains a single record, strtok can be used to get "myvar1", "=", and "120", or "myvar1 " and " 120", depending on the delimiters passed to it.

The strcmp() function can then me used to compare the name portion, so that the value is stored in the correct variable. The atoi() function can convert NULL-terminated char arrays (as returned by strtok) to integers, if needed.

Go Up