Hey everyone!
This is my first post on the forum, so I hope my etiquette is ok! (Please let me know if there is anyway I could make the question clearer/ easier to understand :))
SO I am trying to collect data about the moisture levels of soil (using two electrodes) and print this to a .txt file on an SD card. For testing purposes I am trying print the data to the file 10 times with a 1 second break in between.
Here is the code I'm working with (please excuse bad structure- I'm new and this is a draft)
#include <SPI.h>
#include <SD.h>
int Sensor_1 = 0;
int Sensor_2 = 1;
int Sensor_3 = 2;
int Sensor_4 = 3;
int Val_1;
int Val_2;
int Val_3;
int Val_4;
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
;
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("1 \t 2 \t 3 \t 4");
for (int = 0; i<10, i++) {
Val_1 = analogRead(Sensor_1);
Val_2 = analogRead(Sensor_2);
Val_3 = analogRead(Sensor_3);
Val_4 = analogRead(Sensor_4);
myFile.print(Val_1/10.23, 0);
myFile.print("\t");
myFile.print(Val_2/10.23, 0);
myFile.print("\t");
myFile.print(Val_3/10.23, 0);
myFile.print("\t");
myFile.println(Val_4/10.23, 0);
}
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
I have got the print to file all figured out but it is just the 'for' (which I'm using to repeat the function 10 times) that is problematic.
The error i got was:
error: expected unqualified-id before '=' token
for (int = 0; i<10, i++) {
I think I understand that the 'int' wasn't 'introduced' to begin with- is that correct?
If so how can I make it work?
Thanks for all the help