Pages: [1]   Go Down
Author Topic: How to arduino import var values from text files!!  (Read 2572 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
....
....
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: