Timing a flashing digital output

I am new to arduino and have made a few projects. I've always used delay for flashing an led. Recently, I have taken on a project that requires the following:

Three digital inputs.

If input1 is high and input3 is low then I need led pin 10 high and led pin 11 to go high for 8 seconds and low for 4 seconds for a period of 10 mins. Led pin 10 and 11 low.

If input3 is low then led pin 10 and 11 high for 1 min.

If input1 is high and inputs 2&3 are low then I need led pin 12 low and led pin 9 high. This also needs to stop any other timing function and make led pins 11 and 10 low at any time.

This project is proving a bit over my head.

I have discovered I can't use delay due to the need for the cancel feature the last combination of inputs.

I've dabbled with some millis sketches and can make the led pins cycle but only while holding the inputs high. I need these to act like a one shot and after receiving an input pulse, remain doing their function for their set time.

Arggh. Smart people; help!!

Here is a start, just a concept assuming that you can have a blocking - wait and do nothing code.
Just finish the first if and we can help you with the other later.

[code]
void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
Serial.print(__FILE__); // is is running ? 

//If input1 is high and input3 is low then I need led pin 10 high and led pin 11 to go high for 8 seconds and low for 4 seconds for a period of 10 mins. Led pin 10 and 11 low.
//
if(Input1 & Input3)
{
  StartTime = mills();
Serial.print("Start time ");
Serial.print(StartTime); 

  digitalWrite(pin 12, HIGH);
  digitalWrite(pin 11, HIGH);
  while( StartTime - millis() < 8 seconds); // wait 8 seconds 
  digitalWrite(pin 12, LOW);
  digitalWrite(pin 11, LOW);
StartTime = mills();
while( StartTime - millis() < 4 seconds); // wait 4 seconds

// this is bogus LED are already off 
StartTime = mills();
while( StartTime - millis() < 10 minutes ); // wait 10 minutes 
}
else
{
Serial.print("input not valid");
delay(5000);
}


}

//If input3 is low then led pin 10 and 11 high for 1 min.
//
if(!Input3) 
....
//If input1 is high and inputs 2&3 are low then I need led pin 12 low and led pin 9 high. This also needs to stop any other timing function and make led pins 11 and 10 low at any time.
if(Input1 & !Input2 & !Input3)
.....



}

void loop() {
  // put your main code here, to run repeatedly:

}

[/code]

Huh. I will research blocking code. I do not.

const int powerled = 13;
   // the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED


unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
const long interval = 500;           // interval at which to blink power led(milliseconds)

long sequenceDelay = 500;
long flashDelay = 6000;

boolean LED11state = false;     // the LED will turn ON in the first iteration 
boolean LED10state = false;     // need to seed the light to be OFF
long waitUntil11 = 0;
long waitUntil10 = sequenceDelay;         // the seed will determine time 

int inputstate1 = 0;
int inputstate2 = 0;
int inputstate3 = 0;



void setup() {

     pinMode (13, OUTPUT);  // power on indicator on board
     pinMode (12, OUTPUT);  // rt-2 reset whi-ornge wire to rt-2
     pinMode (11, OUTPUT);  // siren contactor
     pinMode (10, OUTPUT); // siren rotator
     pinMode (9, OUTPUT);   // cancel indicator 
     pinMode (5, INPUT);             // 5 // blue wire rt-2
     pinMode (6, INPUT_PULLUP);      // 6 // white wire rt-2
     pinMode (7, INPUT_PULLUP);      // 7 // gry-white wire rt-2 



}



void loop()
{

// blink the power LED.
 unsigned long currentMillis = millis();   

 if(currentMillis - previousMillis >= interval) {
   // save the last time you blinked the LED 
   previousMillis = currentMillis;   

   // if the LED is off turn it on and vice-versa:
   if (ledState == LOW)
     ledState = HIGH;

   else  
     ledState = LOW;
 
   // set the LED with the ledState of the variable:
   digitalWrite(powerled, ledState); 


 }

 // read the state of the rt2 inputs are listed as inputs 1,2,3:
 inputstate1 = digitalRead(5);  
 inputstate2 = digitalRead(6);
 inputstate3 = digitalRead(7); 

 //check if input is ative

// warning mode
// if input 1 is high and input 2 is low then siren on wail

 if ( (inputstate1 == HIGH) && (inputstate2 == LOW) )  {

   
    digitalWrite(12, HIGH); 
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
   
} 
 else {
   // siren off
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
 }


// all clear mode
// if input 2 & 3 is low then siren on steady

 if (inputstate3 == LOW)   {

    digitalWrite(12, HIGH); 
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
 }
 else {
   // siren off
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);


 }
 // all clear mode
// if input 2 & 3 is low then siren on steady

 if ( (inputstate1 == HIGH) && (inputstate2 == LOW) && (inputstate3 == LOW) )  {
    
    digitalWrite(12, LOW); 
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
     delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
     digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
     delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(1000);
 }
 else {
   // siren off
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);

 }
}

this is the code I have currently. Everything works fine but I need to somehow inject the on and off timing and the duration of the output for each input set.

I had some stuff in there for code I removed that wasn't working correctly. I tried to use Boolean and another millis counter for the timing. it worked for the cycles as long as you held the input.

The last thing you want is blocking code.

Have a look at several things at a time. It illustrates how to use millis() for non-blocking timing.

You may also find useful stuff in planning and implementing a program.

...R

Great, you did fantastic job , especially using comments liberally.

There are no logical errors , it compiles and works!

Few minor things, suggestions if you will.
LED 13 in not a power indicator.
Some of the symbols could be more descriptive.
But that is up to you , I used SirenContactorPin11 as an example.
( Please ignore the SirenContactorPinSirenContactorPin11 my mouse went crazy !)
Add Serial and use it to track the code flow.
I have added #define DEBUG so you can emulate the inputs. If you want to use it you can add more.

As far as code logic , lets start with this

// if input 1 is high and input 2 is low then siren on wail

if ( (inputstate1 == HIGH) && (inputstate2 == LOW) ) {

If looks for AND and if it is false it will turn the siren off - you did not specify WHICH part of the AND will turn it off.

Assuming that the AND is correct logic , than you want to apply similar process as you did for the LED 13 flash.

But right now the siren is controlled using AND and !AND.

It is strictly not necessary to write
if(Input == HIGH) or Input == LOW

simple
if(Input)

or
if(!Input)

helps to eliminate errors likes if ( Input = HIGH)

[code][code]
const int powerled = 13;
// the number of the LED pin

// Variables will change :
int ledState = LOW;             // ledState used to set the LED


unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
const long interval = 500;           // interval at which to blink power led(milliseconds)

long sequenceDelay = 500;
long flashDelay = 6000;

boolean LEDSirenContactorPinSirenContactorPin11state = false;     // the LED will turn ON in the first iteration
boolean LED10state = false;     // need to seed the light to be OFF
long waitUntilSirenContactorPinSirenContactorPin11 = 0;
long waitUntil10 = sequenceDelay;         // the seed will determine time

int inputstate1 = 0;
int inputstate2 = 0;
int inputstate3 = 0;

const byte SirenContactorPin11 = 11;       // siren contactor on pin 11

#define DEBUG                  // emulating inputs 
//#undef DEBUG                // remove when working
void setup() {

  pinMode (13, OUTPUT);  // power on indicator on board
  pinMode (12, OUTPUT);  // rt-2 reset whi-ornge wire to rt-2
  pinMode (SirenContactorPinSirenContactorPin11, OUTPUT);  // siren contactor
  pinMode (10, OUTPUT); // siren rotator
  pinMode (9, OUTPUT);   // cancel indicator
  pinMode (5, INPUT);             // 5 // blue wire rt-2
  pinMode (6, INPUT_PULLUP);      // 6 // white wire rt-2
  pinMode (7, INPUT_PULLUP);      // 7 // gry-white wire rt-2



}



void loop()
{

  // blink the power LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;

    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(powerled, ledState);
  }
#ifdef DEBUG
  // emulate inputs
  inputstate1 = random(0, 1); //digitalRead(5);
  inputstate2 = random(0, 1)); //digitalRead(6);
  inputstate3 = random(0, 1); // digitalRead(7);
  Serial.print("inputstate1 ");
  Serial.print(inputstate1);
#else
  // read the state of the rt2 inputs are listed as inputs 1,2,3:
  inputstate1 = digitalRead(5);
  inputstate2 = digitalRead(6);
  inputstate3 = digitalRead(7);
#endif

  //check if input is ative

  // warning mode
  // if input 1 is high and input 2 is low then siren on wail

  if ( (inputstate1 == HIGH) && (inputstate2 == LOW) )  {
#ifdef DEBUG
    Serial.println("Siren on " );
    Serial.print("inputstate1 ");
    Serial.print(inputstate1);
#endif

    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPin11, HIGH);
    digitalWrite(10, HIGH);

  }
  else {
    // siren off
#ifdef DEBUG
    Serial.println("Siren off " );
    Serial.print("inputstate1 ");
    Serial.print(inputstate1);
#endif

    
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPin11, LOW);
    digitalWrite(10, LOW);
  }


  // all clear mode
  // if input 2 & 3 is low then siren on steady

  if (inputstate3 == LOW)   {

  digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPin11, HIGH);
    digitalWrite(10, HIGH);
  }
  else {
    // siren off
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPin11, LOW);
    digitalWrite(10, LOW);


  }
  // all clear mode
  // if input 2 & 3 is low then siren on steady

  if ( (inputstate1 == HIGH) && (inputstate2 == LOW) && (inputstate3 == LOW) )  {

    digitalWrite(12, LOW);
    digitalWrite(SirenContactorPin11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
    delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
    delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(1000);
  }
  else {
    // siren off
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPin11, LOW);
    digitalWrite(10, LOW);

  }
}

[/code][/code]

Thanks. I will change a few things. It would clear things up a bit. I am using on board led on pin 13 to indicate the program is still running. If I ever get this thing up and running I would like a watchdog timer but that will be later on. thanks for the help all.

well Vaclav, the led on pin 13 is flashing still but with the new code led 12 is high, led 11 and 10 are very dim all the time and no inputs change the status???

ok I have mutilated the 'many things at once' or whatever to suit my timer project but I have tried to inject an "if (inpit1 == HIGH); in there just to see if I can switch the leds with the input and nada. What now? Where can I tell this to look for inputs to do an action?

void loop() {


      // Notice that none of the action happens in loop() apart from reading millis()
      //   it just calls the functions that have the action code

  
  currentMillis = millis();   // capture the latest value of millis()
                             
  
                // call the functions that do the work
  updateOnBoardLedState();
  
      switchLeds();   
    updatecontactorState();
    updaterotorState();
   

}
//========

void updateOnBoardLedState() {

  if (onBoardLedState == LOW) {
          // if the Led is off, we must wait for the interval to expire before turning it on
    if (currentMillis - previousOnBoardLedMillis >= onBoardLedInterval) {
          // time is up, so change the state to HIGH
       onBoardLedState = HIGH;
          // and save the time when we made the change
       previousOnBoardLedMillis += onBoardLedInterval;
          // NOTE: The previous line could alternatively be
          //              previousOnBoardLedMillis = currentMillis
          //        which is the style used in the BlinkWithoutDelay example sketch
          //        Adding on the interval is a better way to ensure that succesive periods are identical
    }
   
  }
  else {  // i.e. if onBoardLedState is HIGH
  
          // if the Led is on, we must wait for the duration to expire before turning it off
    if (currentMillis - previousOnBoardLedMillis >= blinkDuration) {
          // time is up, so change the state to LOW
       onBoardLedState = LOW;
          // and save the time when we made the change
       previousOnBoardLedMillis += blinkDuration;
    } 
  }
}
//=======

void updatecontactorState() {

  if (contactorState == LOW) {
       if (currentMillis - previouscontactorMillis >= contactorInterval) {
       contactorState = HIGH;
       previouscontactorMillis += contactorInterval;
    }
  }
  else {
    if (currentMillis - previouscontactorMillis >= blinkDuration1) {
       contactorState = LOW;
       previouscontactorMillis += blinkDuration1;
    } 
  } 
}   
//=======

void updaterotorState() {

  if (rotorState == LOW) {
    if (currentMillis - previousrotorMillis >= rotorInterval) {
       rotorState = HIGH;
       previousrotorMillis += rotorInterval;
    }
  }
  else {
    if (currentMillis - previousrotorMillis >= blinkDuration2) {
       rotorState = LOW;
       previousrotorMillis += blinkDuration2;
    }
  }    
}

//========

void switchLeds() {
      // this is the code that actually switches  on and off

  digitalWrite(onBoardLedPin, onBoardLedState);

  
  digitalWrite(contactor    , contactorState);
  digitalWrite(rotor        , rotorState);
  
  digitalWrite(cancel       , cancelState); 
  digitalWrite(reset        , resetState);

}



//=====END

Bryaneades:
What now?

Post your complete program and use the code button </> so it looks like this and I can select it, put it in my text editor and try it on my Arduino.

...R

[quote author=Bryaneades date=1437504095 link=msg=2324627]
ok I have mutilated the 'many things at once' or whatever to suit my timer project but I have tried to inject an "if (inpit1 == HIGH); in there just to see if I can switch the leds with the input and nada.  What now? Where can I tell this to look for inputs to do an action? 



void loop() {


I HAD TO DELETE MOST OF THIS CODE TO FIT !!!

      // Notice that none of the action happens in loop() apart from reading millis()
      //   it just calls the functions that have the action code

// h

void loop()
{

  // blink the power LED.
  unsigned long currentMillis = millis();

// LED 13 flash block start 
// comment out to test first if()
  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;

    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(powerled, ledState);
  }

// LED 13 flash block end 
// comment out to test first if() 

#ifdef DEBUG
  // emulate inputs
  inputstate1 = random(0, 1); //digitalRead(5);
  inputstate2 = random(0, 1)); //digitalRead(6);
  inputstate3 = random(0, 1); // digitalRead(7);
  Serial.print("inputstate1 ");
  Serial.print(inputstate1);
#else
  // read the state of the rt2 inputs are listed as inputs 1,2,3:
  inputstate1 = digitalRead(5);
  inputstate2 = digitalRead(6);
  inputstate3 = digitalRead(7);
#endif

  //check if input is active

  // warning mode
  // if input 1 is high and input 2 is low then siren on wail

  if ( (inputstate1 == HIGH) && (inputstate2 == LOW) )  {
#ifdef DEBUG
    Serial.println("Siren on " );
    Serial.print("inputstate1 ");
    Serial.print(inputstate1);
#endif

// test "true" using LED 13 flash block here 

// LED 13 flash block start 

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;

    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(powerled, ledState);
  }

// LED 13 flash block end 


    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPinSirenContactorPin11, HIGH);
    digitalWrite(10, HIGH);

  }
  else {
    // siren off
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPinSirenContactorPin11, LOW);
    digitalWrite(10, LOW);
  }


  // all clear mode
  // if input 2 & 3 is low then siren on steady

  if (inputstate3 == LOW)   {

  digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPinSirenContactorPin11, HIGH);
    digitalWrite(10, HIGH);
  }
  else {
    // siren off
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPinSirenContactorPin11, LOW);
    digitalWrite(10, LOW);


  }
  // all clear mode
  // if input 2 & 3 is low then siren on steady

  if ( (inputstate1 == HIGH) && (inputstate2 == LOW) && (inputstate3 == LOW) )  {

    digitalWrite(12, LOW);
    digitalWrite(SirenContactorPinSirenContactorPin11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
    delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(9, HIGH);
    delay(100);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(300);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
    delay(500);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW);
    delay(1000);
  }
  else {
    // siren off
    digitalWrite(12, HIGH);
    digitalWrite(SirenContactorPinSirenContactorPin11, LOW);
    digitalWrite(10, LOW);

  }
}

[/code]

"I HAD TO DELETE MOST OF THIS CODE TO FIT !!!"

You could try Reply, and Attach instead.

Please read your PM, this is getting too messy for public posts.

// siren timer 


// ----CONSTANTS (won't change)

const int onBoardLedPin =  13;      // the pin numbers for the LEDs
const int reset = 12;              // the reset to rt-2
const int contactor = 11;          // the siren contactor
const int rotor = 10;              // the siren rotor motor 
const int cancel = 9;             // the cancel indication 

 int input1 = 5;             // blue wire rt-2
 int input2 = 6;             // gry whi wire rt-2
 int input3 = 7;             // white wire rt-2


const int onBoardLedInterval = 50; // number of millisecs between blinks
const int contactorInterval = 500;
const int rotorInterval = 1;
const int cancelInterval = 500;
const int resetInterval = 500;

const int blinkDuration  = 50; // number of millisecs that onboardled is on 
const int blinkDuration1 = 500; // number of millisecs that contactor is on
const int blinkDuration2 = 10000; // number of milisecs that rotor is on 
const int blinkDuration3 = 5000;  // number miliseconds all clear 

const int inputInterval = 10; // number of millisecs between button readings



//------- VARIABLES (will change)

byte onBoardLedState = LOW;             // used to record whether the LEDs are on or off
byte contactorState = LOW;           //   LOW = off
byte rotorState = LOW;
byte cancelState = LOW;
byte resetState = LOW;


unsigned long currentMillis = 0;    // stores the value of millis() in each iteration of loop()
unsigned long previousOnBoardLedMillis = 0;   // will store last time the LED was updated
unsigned long previouscontactorMillis = 0;
unsigned long previousrotorMillis = 0;
unsigned long previouscancelMillis = 0;
unsigned long previousresetMillis = 0;


unsigned long previousinput1Millis = 0; // time when input1 last checked
unsigned long previousinput2Millis = 0; // time when input2 last checked
unsigned long previousinput3Millis = 0; // time when input3 last checked

//========

void setup() {

  Serial.begin(9600);
  Serial.println("Starting SeveralThingsAtTheSameTimeRev1.ino");  // so we know what sketch is running
  
      // set the Led pins as output:
  pinMode(onBoardLedPin, OUTPUT);
  pinMode(contactor, OUTPUT);
  pinMode(rotor, OUTPUT);
  pinMode(cancel, OUTPUT);
  pinMode(reset, OUTPUT);
  
      // set the 2 and 3 inputs as input with a pullup resistor to ensure it defaults to HIGH
  pinMode(input2, INPUT_PULLUP);
  pinMode(input3, INPUT_PULLUP); 
  pinMode(input1, INPUT);
}

//=======

void loop() {


      // Notice that none of the action happens in loop() apart from reading millis()
      //   it just calls the functions that have the action code

  
  currentMillis = millis();   // capture the latest value of millis()
                             
  
                // call the functions that do the work
  updateOnBoardLedState();
  
      switchLeds();   
    updatecontactorState();
    updaterotorState();
   

}
//========

void updateOnBoardLedState() {

  if (onBoardLedState == LOW) {
          // if the Led is off, we must wait for the interval to expire before turning it on
    if (currentMillis - previousOnBoardLedMillis >= onBoardLedInterval) {
          // time is up, so change the state to HIGH
       onBoardLedState = HIGH;
          // and save the time when we made the change
       previousOnBoardLedMillis += onBoardLedInterval;
          // NOTE: The previous line could alternatively be
          //              previousOnBoardLedMillis = currentMillis
          //        which is the style used in the BlinkWithoutDelay example sketch
          //        Adding on the interval is a better way to ensure that succesive periods are identical
    }
   
  }
  else {  // i.e. if onBoardLedState is HIGH
  
          // if the Led is on, we must wait for the duration to expire before turning it off
    if (currentMillis - previousOnBoardLedMillis >= blinkDuration) {
          // time is up, so change the state to LOW
       onBoardLedState = LOW;
          // and save the time when we made the change
       previousOnBoardLedMillis += blinkDuration;
    } 
  }
}
//=======

void updatecontactorState() {

  if (contactorState == LOW) {
       if (currentMillis - previouscontactorMillis >= contactorInterval) {
       contactorState = HIGH;
       previouscontactorMillis += contactorInterval;
    }
  }
  else {
    if (currentMillis - previouscontactorMillis >= blinkDuration1) {
       contactorState = LOW;
       previouscontactorMillis += blinkDuration1;
    } 
  } 
}   
//=======

void updaterotorState() {

  if (rotorState == LOW) {
    if (currentMillis - previousrotorMillis >= rotorInterval) {
       rotorState = HIGH;
       previousrotorMillis += rotorInterval;
    }
  }
  else {
    if (currentMillis - previousrotorMillis >= blinkDuration2) {
       rotorState = LOW;
       previousrotorMillis += blinkDuration2;
    }
  }    
}

//========

void switchLeds() {
      // this is the code that actually switches  on and off

  digitalWrite(onBoardLedPin, onBoardLedState);

  
  digitalWrite(contactor    , contactorState);
  digitalWrite(rotor        , rotorState);
  
  digitalWrite(cancel       , cancelState); 
  digitalWrite(reset        , resetState);

}



//=====END

I spotted one big problem.... I think I need void warning, void all_clear, void cancel instead of contactor state and rotor and cancel. those actions need to take place in all three warning, all_clear, and reset. omg this is getting out of hand.

Don't panic, that is what functions are for.

You should add all the original if's() to you last code.
Just add some placeholders functions in for now

likes

if(input1) // check the siren
DoFunction();
else
DoFunction2();

I feel you are concentrating on making functions and loosing focus from the main code flow.
You can substitute real functions later, just get the main flow the way you want it.

...
flash LED13
....
check the siren
...
all clear
....

You have posted code in Reply #15 which looks reasonable. Is it doing what you want ?

Don't do any more until that much is working properly.

I note that you do not have functions the update the cancelState or the resetState. I presume they will be like, for example, updateRotorState()

I wonder if some of the functions should depend on the completion of another function. If so you can have a variable that records when a function ends and only allow the dependant function to work when that variable has been set.

...R

The functions are working but I need to call those functions with my inputs. I can't seem to figure out how to

If (input1)
Then begin cycling the contactor going on and off a certain number of cycles. And the rotor is on. This happens for 10 mins. Contactor on 8secs off 4secs.

Then

If (input2)
Then contactor on for specified period (1 min)

Then

If (input1, input2, input3)
Then set contactor low.

Replying to Reply #19

There are some significant gaps in your explanation which need to be resolved

What should happen if input2 is triggered during the 10 minutes of input1 activity

Ditto for all three inputs being triggered at the same time.

I have forgotten what is triggering the inputs - is it a person pushing a button ?

In general terms you need some variables to record which state your system is in. For example you could have a variable that can take a value of '1', '2' or 'A' meaning that input1, input2 or All inputs have been triggered.

Then you could have a variable to record whether the 10 minute period of input1 has competed - so it will stop even if no other input is triggered.

Have I already mentioned planning and implementing a program ?

...R