Compling Mystery

I have a mystery stumping this newbe.

As you can see in the attached screen shot you can see one line ( #76) complies, but not line (#88).

The error message:

Arduino: 1.6.11 (Windows 10), Board: “Adafruit Feather M0 (Native USB Port)”

C:\Users\Rocket Nut\Documents\SpairCraft 2\DataLogger\Software Sketches\ExampleLoggingSketch\LoggingTST\DataLoger_V2\DataLoger_V2.ino: In function ‘void ParseCommand(String)’:

DataLoger_V2:76: error: ‘PyroPin’ was not declared in this scope

digitalWrite(PyroPin[PyroNum], HIGH);

^

DataLoger_V2:88: error: ‘PyroPin’ was not declared in this scope

digitalWrite(PyroPin[PyroNum], HIGH);

^

exit status 1

‘PyroPin’ was not declared in this scope

This report would have more information with

“Show verbose output during compilation”

option enabled in File → Preferences.

Rocket Nut

Post the code, using code tags, not a screen shot.

The error message is completely clear: for both lines 76 and 88, PyroPin is not defined within the scope of that block.

OK here is the code:

/*
  Logging Test
*/

#include <SPI.h>
#include <SD.h>
//#include <MsTimer2.h>

// Set the pins used
#define cardSelect 4
#define BoardLED 13
#define SimLED 8

// Define Pyro Firing Control Pins
int PyroPins[] = {14,15,16,17,18,19};
int PyroStatus[6];


// Other Gobal Varables Assignment
volatile int SampleNumber = -1000;
volatile unsigned long time;

File logfile;

//Write Data To SIM Card
void LogData()
{

  digitalWrite(SimLED, HIGH);
  delay(50);
  // Log Test Info
  logfile.print("Sample = "); logfile.print(SampleNumber); logfile.print(" || "); logfile.print("Time = "); logfile.println(time);
  digitalWrite(SimLED, LOW);
}

void DisplayData()
{
  Serial.print("Sample = ");
  Serial.print(SampleNumber);
  Serial.print(" || ");
  Serial.print("Time = ");
  Serial.print(time);
  Serial.print(" || ");
  Serial.print("A1 = ");
  Serial.println(analogRead(7));

}

void ParseCommand(String com)
{
  String Part1;
  String Part2;

//Remove any spaces
  com.replace(" ", "");
  
// Separate the command from the entried string.
// Command format "command(part1)>(delimiter)varables(part2)" Expample -> Start loging at 100 samples per second.
//     the comand string is "StartLoging>100"
  Part1 = com.substring(0, com.indexOf(">"));
  Part2 = com.substring(com.indexOf(">")+1);

  if(Part1.equalsIgnoreCase("firepyro"))
  {
    int PyroNum;
    int PyroFireTime = millis() + 250; //Pyro Firing Pulse Width
    if(Part2.length() == 0)
    {
      Serial.println("Firing Pyro << No Pyro Number");
    }  
    else if(Part2.length() == 1)
    {
     PyroNum = Part2.toInt() - 1; 
     digitalWrite(PyroPin[PyroNum], HIGH);
     PyroStatus[PyroNum] = PyroFireTime;      
     Serial.print("   Firing Pyro ");Serial.print(Part2);Serial.print(" || ");Serial.println(PyroNum);
    }
    else
    {
      while(Part2.length() > 0)
      {
       Part1 = Part2;
       Part1 = com.substring(0, com.indexOf(","));
       Part2 = com.substring(com.indexOf(",")+1);
       PyroNum = Part1.toInt() - 1;
       if(PyroNum >= 0 && PyroNum <= 5)
       {
        Serial.print("   Firing Pyro ");Serial.print(Part1);Serial.print("|| ");Serial.println(Part2.length());
        digitalWrite(PyroPin[PyroNum], HIGH); 
        PyroStatus[PyroNum] = PyroFireTime;
       }
       else
       {
         Serial.print("Firing Pyro > Pyro Num Error ");Serial.println(PyroNum);
//Exit while loop         
         Part2 = "";
       }

      }
    }
  }
  else if(Part1.equalsIgnoreCase("startlogging"))
  {
   Serial.print("Logging Has Started || Samples Pre Second");Serial.println(Part2);  
  }
  else
  {
   Serial.println("Command Not Reconginzed");
   }
  Serial.print("Command => "); Serial.println(com);
}


// blink out an error code
void error(uint8_t errno)
{
  while (1)
  {
    uint8_t i;
    for (i = 0; i < errno; i++)
    {
      digitalWrite(BoardLED, HIGH);
      delay(750);
      digitalWrite(BoardLED, LOW);
      delay(500);
    }
    for (i = errno; i < 10; i++) {
      delay(800);
    }
  }
}

// This line is not needed if you have Adafruit SAMD board package 1.6.2+
// #define Serial SerialUSB

void setup()
{

 // Assign Pyro Output pins
   for(int thisPin = 0; thisPin < 7; thisPin++)
  {
    pinMode(PyroPins[thisPin], OUTPUT);
  }
// Assign misc Output pins
  pinMode(BoardLED, OUTPUT);


  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  Serial.println("\r\nAnalog logger test");

  // see if the card is present and can be initialized:
  if (!SD.begin(cardSelect))
  {
    Serial.println("Card init. failed!");
    error(2);
  }
  char filename[15];
  strcpy(filename, "ANALOG00.TXT");
  for (uint8_t i = 0; i < 100; i++)
  {
    filename[6] = '0' + i / 10;
    filename[7] = '0' + i % 10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename))
    {
      break;
    }
  }

  logfile = SD.open(filename, FILE_WRITE);
  if ( ! logfile )
  {
    Serial.print("Couldnt create ");
    Serial.println(filename);
    error(3);
  }
  Serial.print("Writing to ");
  Serial.println(filename);

  pinMode(SimLED, OUTPUT);
  Serial.println("Ready!");
  delay(250);

  //  MsTimer2::set(500, LogData); // 500ms period
  //  MsTimer2::start();
}

uint8_t i = 0;
String command;

void loop()
{
  if (Serial.available())
  {
    char c = Serial.read();

    if ( c == '\n')
    {

      ParseCommand(command);
      command = "";
    }
    else
    {
      command += c;
      ParseCommand(command);
    }
  }

  time = millis();
  LogData();

  // Display Test Info
  DisplayData();

  digitalWrite(PyroPins[1], HIGH);
  delay(300);

  digitalWrite(BoardLED, HIGH);

  delay(250);

  digitalWrite(BoardLED, LOW);

  delay(250);

  digitalWrite(PyroPins[1], LOW);

  delay(250);

  SampleNumber ++;

}

The PyroPin array is defined at line #15, and Pyro Output pins are assigned at line #139.

You’re declaring PyroPins and using PyroPin.

Thanks lyndon :oops: