Here is the main loop sketch code:
//==========================================
void loop()
{
ResetPyro(); // Check pyro pins to be turned off
UserSketch(); // Do user code
// Generate the out put string
DataStringGen();
// If in Logging mode then save Data String to the SD Card
if(Logging)
{
digitalWrite(SIM_LED, HIGH);
delay(10);
logfile.println(Data_String);
digitalWrite(SIM_LED, LOW);
}
// If USB is connect then check for a command
while(Serial.available()&& digitalRead(USB_Status))
{
char c = Serial.read();
if ( c == '\n')
{
ParseCommand(command);
command = "";
break;
}
else
{
command += c;
}
}
// If USB is connected the send data to ground computer.
if(digitalRead(USB_Status))
{
for(int x = 0; (x<= Data_String.length()&& digitalRead(USB_Status)); x++)
{
if(!digitalRead(USB_Status))
{
Serial.print(Data_String.charAt(x));
}
else
{
break;
}
}
if(digitalRead(USB_Status))
{
Serial.println("");
}
}
digitalWrite(BoardLED, LOW);
// Flash some leds to see it sketch is working
for(int thisPin = 0; thisPin < 6; thisPin++)
{
digitalWrite(PyroPin[thisPin],HIGH);
delay(250);
digitalWrite(PyroPin[thisPin],LOW);
}
digitalWrite(BoardLED, HIGH);
delay(250);
Sample ++;
}