Pages: [1]   Go Down
Author Topic: Use SD card for settings  (Read 539 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I make device on Arduino mega (and now I creating PCB) with many settings. I want use SD card to save settings (on computer) to file and use this values to my program.

I see how I can read file, but I don't know how I can read 1st line and write this "value" to my variable, 2nd to another etc...
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, if you have stored values in a text file, you have to
  • Make a char array or String big enough to hold a line
  • Read a line into the char array by reading chars until you hit a newline character "\n"
  • in the char array, find the part of the line where your value starts
  • Read that value, but if it's a number make sure to convert it from char to int() with the conversion function

There are some helpful functions manipulating character arrays on this page
http://www.cplusplus.com/reference/cstring/
Logged

Pages: [1]   Go Up
Jump to: