First off big thanks to those knowledgeable people that contribute on this site - you have saved me hours, given me ideas and generally made this a fun hobby.
Ok so I have totally confused myself somewhat and need some help please.
I have written a quite lengthy sketch for the Arduino Mega (I needed lots of pins) and it does what I want it to do in controlling a home made geared camera head - it’s a bit like an electronic motor controlled tri pod (lots of reasons I wanted to do this)
One annoying thing is you have to go through each of the menus I created setting certain variables to the required setting each time it is powered on. these are obviously declared and defaulted in the void.setup part of the sketch. e.g.
int tilDegree = 0; // number of degrees per photo to tilt - 1,2,3,4 or 5
int tilDirec = 2; //chosen Tilt direction 2 (up) or 3 (down)
int rotDegree = 0; //number of degrees per photo to rotate. - 1,2,3,4 or 5
int rotDirec = 0; //chosen Rotational direction 0 (right) or 1 (Left)
… There is actually about 20 settings
So I thought it would be nice to use a sd card (given they are so cheap) to store the last settings used and even have different cards with different data settings for particular types and scenarios of use.
I am using the IDE 1.0.5 supplied SD library a adafruit sd card breakout http://www.adafruit.com/products/254 and a micro SD card formatted FAT16. and for testing only, it’s all plugged into a Uno rev3.(main sketch is not included for testing to make things simpler) pins are the standard 13, 12, 11 and 10 on the UNO 53, 52, 51 and 50 when it gos to the mega.
I can get it to work in so far as it will write the txt file to the SD card and store a value for each variable:
myFile.println(tilDegree); //writes the value of ‘variable’ to the text file
myFile.println(tilDirec); //writes the value of ‘variable’ to the text file
These lines are added to the Read/Write sketch by David A. Mellis in the bit where it writes data. unaltered file attached
But the bit I am confused by is how to pull it back the other way, as in read the card and assign the data in the txt file to each respective variable. So line 1 would be the data to assign to tilDegree, line 2 would be the data to assign to tilDirec …and so on.
I have read that this is possible but haven’t found details on how. the problem is I have now read so many posts on forums and howto documents I am no longer sure what is actually needed.
Can someone please help as i am quite stuck here? is there any more info I need to share?
ReadWrite.ino (2.42 KB)