Go Down

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

lutecky

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

capsid

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/

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy