Go Down

Topic: Use SD card for settings (Read 666 times) previous topic - next topic


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


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

Go Up