I am trying to use an sd card as a way to keep values in a float array after turning off my arduino. I've been working on some code for it and I can save my array into the sd card without any issues. Where I am having trouble is when I go to save the data back into RAM. Any help would be appreciated. The code I have is below.
#include <SPI.h>
#include <SD.h>
void setup() {
File numFile;
Serial.begin(9600);
while (!Serial) {
;
}
if (!SD.begin(10)) {
Serial.println("SD Error");
while (1);
}
SD.remove("nums.txt");
//counter
int i = 0;
float nums[7] = {16.1, 16.2, 16.3, 16.4, 16.5, 16.6, 16.7};
float numsFromSD[7];
// Make File
numFile = SD.open("nums.txt", FILE_WRITE);
//Save array to SD
for (i = 0; i <= 6; i++) {
numFile.println(nums[i]);
}
numFile.close();
i=0;
//Where I am stumped
numFile = SD.open("nums.txt");
if (numFile) {
// read file
while (numFile.available()) {
Serial.write(numFile.read());
}
// close the file:
numFile.close();
}
}
void loop() {
}