Hi All,
First of all, I apologize for my messy code. I'm honestly kind of embarrassed about it, which is why I took so long to post it on here. However, my brain is now fried and I am making no progress after about 7 hours of research (I'm not the best researcher...) and debugging, so this is my call of desperation.
I'm doing a project for work that includes gathering a bunch of data from various sensors and I want to put it on an SD card. However, when I include the "myFile = SD.open(filename, FILE_WRITE);" line, my code doesn't seem to even go through the loop.
I'm probably missing something simple, but my programming skills are weak at best.
My whole code is too large to include here, but I've included it as an attachment.
Here's the main loop:
void loop()
{
if (Serial.available() > 0)
{
incomingByte = Serial.read(); // read the incoming byte:
//after 10000 cycles, the test stops
while (testDuration < 10000)
{
// run the simple timer
timer.run();
//i counts how many cycles pass
if (i < 55)
{
if (fileFlag == true)
{
cycleSeq();//Run the whole cycle
Serial.println(fileFlag);
}
if (fileFlag == false)//create the file and write data to it
{
getFileName();
// createFileName();
myFile = SD.open(filename, FILE_WRITE);//Open the file to write something to it
myFile.println("pumpOn , valveOpen , vent1Open, vent2Open , valve1Open , valve2Open , outValveOpen , inValveOpen , heaterOn"); //print header to file
myFile.close();
Serial.println(fileFlag);
delay (500);
fileFlag = true;
}
}
//after 55 cycles, run thermal cycle
if (i >= 55)
{
cooldownWarmup();
}
//shows values in serial monitor
valueCase();
//stop test
if (incomingByte == 's')
{
Serial.print ("stop");
testDuration = 10000;
}
}
}
}
Thanks to anyone willing to take a look.
ValveTestLogger141216.ino (19 KB)