Switch case problem

This is a program that has three different pushbutton inputs. Both the demo and lock sub-sketches work, but the switch case statement for the storm sketch is not progressing past the first case(case=1)
Any idea why? Im using the switch case statements in the following manner.

1.) once the storm trigger is detected, set switch variable to 1.
2.) now that the switch variable is equal to one, case 1 will run and exit until the enclosed if statements time requirement is met, an output then takes place, then one is added to the switch variable to progress it to case two.
3.) repeat until end.

const int fogger = 11;
const int mister = 12;
const int music = 6;
const int shutoff = 7;
const int lock = 8;
const int stormTrigger = 9;
const int momentaryTrigger = 13;
const int lockTrigger = 10;

int stState = LOW; //Initaialize Storm trigger State
int mtState = LOW; //Initialize momentary fog/mist trigger state
int ltState = LOW; //Initialize lock state :)

long lastSTDebounceTime = 0;//last time these were debounced
long lastMTDebounceTime = 0;
long lastLTDebounceTime = 0;

long debounceDelay = 200;// the debounce time

int const lockTime = 3000;//sets the time for lock to be unlocked
int unlockStartTime =  0;//Keeps track of when unlock started

int const demoFoggerTime = 120000;
int const demoMisterTime = 5000;
int momentaryFogTime = 0;//Keeps track of fog start time
int momentaryMisterTime = 0; // leeps track of mister start time


int switchValue = 0; //tracks switch value
int stormStartTime = 0; //tracks storm time
int stormIntervalTime = 0;//tracks time between events
 
void setup() {
  
pinMode(fogger, OUTPUT);
pinMode(mister, OUTPUT);
pinMode(music, OUTPUT);
pinMode(shutoff, OUTPUT);
pinMode(lock, OUTPUT);
pinMode(stormTrigger, INPUT);
pinMode(momentaryTrigger, INPUT);
pinMode(lockTrigger, INPUT);

digitalWrite(fogger, HIGH);
digitalWrite(mister, HIGH);
digitalWrite(music, HIGH);
digitalWrite(shutoff,HIGH);


}
  
    
    
void loop(){
  
  
   /////LOCK SKETCH////
   
   ltState = digitalRead(lockTrigger); //read locktrigger high/low and put value in ltState Variable
   
   if( (millis() - lastLTDebounceTime) >= debounceDelay) { //if current time - last debounce for trigger is > 200ms then
   
     if (ltState == HIGH){ //If Lock trigger is being pushed 
       
     digitalWrite(lock, LOW); // Turns on lock
     
     lastLTDebounceTime = millis(); //SET last Lock debounce to current time
     unlockStartTime = millis(); //SET unlock start time to current time
     
     }}
     
     if ( (millis() - unlockStartTime) >= lockTime) { //If current time- the time when the lock opened is >= to variable =3000 then close
     digitalWrite(lock, HIGH);
     
     }
     
     
     
     
     ////Mister/Fogger Demo Sketch///
     
     mtState = digitalRead(momentaryTrigger); //Read momentary trigger
     
     if( (millis() - lastMTDebounceTime) >= debounceDelay) { //if current time- last debounce for momentary trigger is >= 200ms then
     
     
     if ((mtState == HIGH) && (switchValue == 0)) { //if momentary switch is on and the storm is NOT ocurring
     
     digitalWrite(fogger, LOW); 
     digitalWrite(mister, LOW);
     
     lastMTDebounceTime = millis();  //set mt trigger debounce time to current
     momentaryFogTime = millis(); //set fogger time
     momentaryMisterTime = millis();// set mister Time
     
     }}
     
     if ( (millis() - momentaryFogTime) >= demoFoggerTime) { //If current time- the time when the fogger has been going is >= to variable =120000 then switch off
     digitalWrite(fogger, HIGH);
     
     }
     
     if ( (millis() - momentaryMisterTime) >= demoMisterTime) { //If current time- the time when the mister has been going is >= to variable = 5000 then switch off
     digitalWrite(mister, HIGH);
     
     }

     
     
  //Storm Mode//
  
  stState = digitalRead(stormTrigger);//read storm trigger
  
  if( ((millis() - lastSTDebounceTime) >= debounceDelay) && (switchValue == 0)) { //if current time- last debounce time is >=200ms then
  
  if ((stState == HIGH) && (switchValue == 0)) {
    
    switchValue=1; //n
    
    stormStartTime = millis();//set event start time to current time
  }}
  
  
  switch(switchValue) {
    
    case 1: 
    
    if ((millis()- stormStartTime) >= 100) {
      digitalWrite(music, LOW);//music on
      digitalWrite(fogger, LOW);//LOW is on???
      digitalWrite(shutoff, LOW);
      stormIntervalTime = millis();//set varialbe to current time    
      switchValue+1;
      delay(20);
    }
      break;
  
   
    case 2: ////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,LOW);
    digitalWrite(music,HIGH); //music back off
   stormIntervalTime = millis(); 
    switchValue+1; 
    delay(20);
  }
     break;
    
    case 3:///// 
      if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue+1;  
  }
    
    
    break;
    
    case 4: /////
     if ((millis() - stormIntervalTime) >=6000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1;  
  }
    
    break;
    
    case 5: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1; 
    }
    break;
    
    case 6: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue+1;  
  }
    
    break;
    
       case 7: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1; 
    }
    break;
    
    case 8: ///////
    
       if ((millis() - stormIntervalTime) >=12000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1; 
  }
    
    break;    
    
    case 9: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1;  
    }
    break;
    
    case 10: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1;  
  }
    
    break;    
    
    case 11: ////////
    if ((millis() - stormIntervalTime) >= 4000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1;  
    }
    break;
    
    case 12: ///////
    
       if ((millis() - stormIntervalTime) >=13000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1; 
  }
    
    break;   
   
    case 13: ////////
    if ((millis() - stormIntervalTime) >= 2000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1;  
    }
    break;
    
    case 14: ///////
    
       if ((millis() - stormIntervalTime) >=15000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue+1;  
  }
    
    break;
    
        case 15: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue+1; 
    }
    break;
    
    case 16: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1;  
  }
    
    break;
    
            case 17: ////////
    if ((millis() - stormIntervalTime) >= 1500){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1; 
    }
    break;
    
    case 18: ///////
    
       if ((millis() - stormIntervalTime) >=14000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1;  
  }
    
    break;
    
            case 19: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue+1;  
    }
    break;
    
    case 20: ///////
    
       if ((millis() - stormIntervalTime) >=18000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue+1;  
  }
    
    break;
    
     case 21: ///////
    
       if ((millis() - stormIntervalTime) >=2000){
    digitalWrite(mister,HIGH); 
    digitalWrite(fogger, HIGH);//LOW is on???
      digitalWrite(shutoff, HIGH);
  stormIntervalTime = millis();  
    switchValue = 0;
       }
    break;
    
    
  }}

What is this??
switchValue+1;
OR
do you want switchValue= switchValue+1;
OR
switchValue++;

switchValue+1 does absolutely nothing of value. It reads switchValue, adds 1 to it, then throws the result away. Most likely, the compiler discards the whole thing, and no code is generated at all.

What you want is one of:

switchValue = switchValue+1;

or

switchValue++;

or

++switchValue;

Regards,
Ray L.

Hello,
I originaly did use switchValue++
But that wasn't working either. I must of had a brainfart and accidentally kept the increment like syntax when setting a variable = to itself + 1. Am I missing something else up with the timing? Is there a better way to do this? Better way to Sequence events to ocurr?
Thanks for the help.

Current code still not functioning for switch case

const int fogger = 11;
const int mister = 12;
const int music = 6;
const int shutoff = 7;
const int lock = 8;
const int stormTrigger = 9;
const int momentaryTrigger = 13;
const int lockTrigger = 10;

int stState = LOW; //Initaialize Storm trigger State
int mtState = LOW; //Initialize momentary fog/mist trigger state
int ltState = LOW; //Initialize lock state :)

long lastSTDebounceTime = 0;//last time these were debounced
long lastMTDebounceTime = 0;
long lastLTDebounceTime = 0;

long debounceDelay = 200;// the debounce time

int const lockTime = 3000;//sets the time for lock to be unlocked
int unlockStartTime =  0;//Keeps track of when unlock started

int const demoFoggerTime = 120000;
int const demoMisterTime = 5000;
int momentaryFogTime = 0;//Keeps track of fog start time
int momentaryMisterTime = 0; // leeps track of mister start time


int switchValue = 0; //tracks switch value
int stormStartTime = 0; //tracks storm time
int stormIntervalTime = 0;//tracks time between events
 
void setup() {
  
pinMode(fogger, OUTPUT);
pinMode(mister, OUTPUT);
pinMode(music, OUTPUT);
pinMode(shutoff, OUTPUT);
pinMode(lock, OUTPUT);
pinMode(stormTrigger, INPUT);
pinMode(momentaryTrigger, INPUT);
pinMode(lockTrigger, INPUT);

digitalWrite(fogger, HIGH);
digitalWrite(mister, HIGH);
digitalWrite(music, HIGH);
digitalWrite(shutoff,HIGH);


}
  
    
    
void loop(){
  
  
   /////LOCK SKETCH////
   
   ltState = digitalRead(lockTrigger); //read locktrigger high/low and put value in ltState Variable
   
   if( (millis() - lastLTDebounceTime) >= debounceDelay) { //if current time - last debounce for trigger is > 200ms then
   
     if (ltState == HIGH){ //If Lock trigger is being pushed 
       
     digitalWrite(lock, LOW); // Turns on lock
     
     lastLTDebounceTime = millis(); //SET last Lock debounce to current time
     unlockStartTime = millis(); //SET unlock start time to current time
     
     }}
     
     if ( (millis() - unlockStartTime) >= lockTime) { //If current time- the time when the lock opened is >= to variable =3000 then close
     digitalWrite(lock, HIGH);
     
     }
     
     
     
     
     ////Mister/Fogger Demo Sketch///
     
     mtState = digitalRead(momentaryTrigger); //Read momentary trigger
     
     if( (millis() - lastMTDebounceTime) >= debounceDelay) { //if current time- last debounce for momentary trigger is >= 200ms then
     
     
     if ((mtState == HIGH) && (switchValue == 0)) { //if momentary switch is on and the storm is NOT ocurring
     
     digitalWrite(fogger, LOW); 
     digitalWrite(mister, LOW);
     
     lastMTDebounceTime = millis();  //set mt trigger debounce time to current
     momentaryFogTime = millis(); //set fogger time
     momentaryMisterTime = millis();// set mister Time
     
     }}
     
     if ( (millis() - momentaryFogTime) >= demoFoggerTime) { //If current time- the time when the fogger has been going is >= to variable =120000 then switch off
     digitalWrite(fogger, HIGH);
     
     }
     
     if ( (millis() - momentaryMisterTime) >= demoMisterTime) { //If current time- the time when the mister has been going is >= to variable = 5000 then switch off
     digitalWrite(mister, HIGH);
     
     }

     
     
  //Storm Mode//
  
  stState = digitalRead(stormTrigger);//read storm trigger
  
  if( ((millis() - lastSTDebounceTime) >= debounceDelay) && (switchValue == 0)) { //if current time- last debounce time is >=200ms then
  
  if ((stState == HIGH) && (switchValue == 0)) {
    
    switchValue=1; //n
    
    stormStartTime = millis();//set event start time to current time
  }}
  
  
  switch(switchValue) {
    
    case 1: 
    
    if ((millis()- stormStartTime) >= 100) {
      digitalWrite(music, LOW);//music on
      digitalWrite(fogger, LOW);//LOW is on???
      digitalWrite(shutoff, LOW);
      stormIntervalTime = millis();//set varialbe to current time    
      switchValue=switchValue+1;
   
    }
    break;
      
  
   
    case 2: ////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,LOW);
    digitalWrite(music,HIGH); //music back off
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;
   
  }
    break;  
    
    case 3:///// 
      if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue=switchValue+1;  
  }
    
    
    break;
    
    case 4: /////
     if ((millis() - stormIntervalTime) >=6000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    break;
    
    case 5: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    break;
    
    case 6: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue=switchValue+1;  
  }
    
    break;
    
       case 7: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    break;
    
    case 8: ///////
    
       if ((millis() - stormIntervalTime) >=12000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1; 
  }
    
    break;    
    
    case 9: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    break;
    
    case 10: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    break;    
    
    case 11: ////////
    if ((millis() - stormIntervalTime) >= 4000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    break;
    
    case 12: ///////
    
       if ((millis() - stormIntervalTime) >=13000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1; 
  }
    
    break;   
   
    case 13: ////////
    if ((millis() - stormIntervalTime) >= 2000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    break;
    
    case 14: ///////
    
       if ((millis() - stormIntervalTime) >=15000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue=switchValue+1;  
  }
    
    break;
    
        case 15: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue=switchValue+1; 
    }
    break;
    
    case 16: ///////
    
       if ((millis() - stormIntervalTime) >=8000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    break;
    
            case 17: ////////
    if ((millis() - stormIntervalTime) >= 1500){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    break;
    
    case 18: ///////
    
       if ((millis() - stormIntervalTime) >=14000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    break;
    
            case 19: ////////
    if ((millis() - stormIntervalTime) >= 3000){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    break;
    
    case 20: ///////
    
       if ((millis() - stormIntervalTime) >=18000){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    break;
    
     case 21: ///////
    
       if ((millis() - stormIntervalTime) >=2000){
    digitalWrite(mister,HIGH); 
    digitalWrite(fogger, HIGH);//LOW is on???
      digitalWrite(shutoff, HIGH);
  stormIntervalTime = millis();  
    switchValue = 0;
       }
    break;
    
    
  }}

I have not gone trough the full thought process in your sketch but:
Have you placed Serial.print debug statements at strategic places to prove what values are there when you think they are there?

Yes, and I see the switchValue variable change up to 21 then back to zero accordingly. the mister is on correct pin and works when

digitalWrite (mister, LOW);

in other sketches.

Most recent revision. Still not functioning. Now will get to switchValue=2 before stopping

const int fogger = 11;
const int mister = 12;
const int music = 6;
const int shutoff = 7;
const int lock = 8;
const int stormTrigger = 9;
const int momentaryTrigger = 13;
const int lockTrigger = 10;

int stState = LOW; //Initaialize Storm trigger State
int mtState = LOW; //Initialize momentary fog/mist trigger state
int ltState = LOW; //Initialize lock state :)

long lastSTDebounceTime = 0;//last time these were debounced
long lastMTDebounceTime = 0;
long lastLTDebounceTime = 0;

long debounceDelay = 200;// the debounce time

int const lockTime = 3000;//sets the time for lock to be unlocked
int unlockStartTime =  0;//Keeps track of when unlock started

int const demoFoggerTime = 120000;
int const demoMisterTime = 5000;
int momentaryFogTime = 0;//Keeps track of fog start time
int momentaryMisterTime = 0; // leeps track of mister start time



int stormStartTime = 0; //tracks storm time
int stormIntervalTime = 0;//tracks time between events
 int switchValue=0;
 
void setup() {
  
  
pinMode(fogger, OUTPUT);
pinMode(mister, OUTPUT);
pinMode(music, OUTPUT);
pinMode(shutoff, OUTPUT);
pinMode(lock, OUTPUT);
pinMode(stormTrigger, INPUT);
pinMode(momentaryTrigger, INPUT);
pinMode(lockTrigger, INPUT);

digitalWrite(fogger, HIGH);
digitalWrite(mister, HIGH);
digitalWrite(music, HIGH);
digitalWrite(shutoff,HIGH);


}
  
    
    
void loop(){
  

  
   /////LOCK SKETCH////
   
   ltState = digitalRead(lockTrigger); //read locktrigger high/low and put value in ltState Variable
   
   if( (millis() - lastLTDebounceTime) >= debounceDelay) { //if current time - last debounce for trigger is > 200ms then
   
     if (ltState == HIGH){ //If Lock trigger is being pushed 
       
     digitalWrite(lock, LOW); // Turns on lock
     
     lastLTDebounceTime = millis(); //SET last Lock debounce to current time
     unlockStartTime = millis(); //SET unlock start time to current time
     
     }}
     
     if ( (millis() - unlockStartTime) >= lockTime) { //If current time- the time when the lock opened is >= to variable =3000 then close
     digitalWrite(lock, HIGH);
     
     }
     
     
     
     
     ////Mister/Fogger Demo Sketch///
     
     mtState = digitalRead(momentaryTrigger); //Read momentary trigger
     
     if( (millis() - lastMTDebounceTime) >= debounceDelay) { //if current time- last debounce for momentary trigger is >= 200ms then
     
     
     if ((mtState == HIGH) && (switchValue == 0)) { //if momentary switch is on and the storm is NOT ocurring
     
     digitalWrite(fogger, LOW); 
     digitalWrite(mister, LOW);
     
     lastMTDebounceTime = millis();  //set mt trigger debounce time to current
     momentaryFogTime = millis(); //set fogger time
     momentaryMisterTime = millis();// set mister Time
     
     }}
     
     if ( (millis() - momentaryFogTime) >= (demoFoggerTime)) { //If current time- the time when the fogger has been going is >= to variable =120000 then switch off
     digitalWrite(fogger, HIGH);
     
     }
     
     if ( (millis() - momentaryMisterTime) >= (demoMisterTime)) { //If current time- the time when the mister has been going is >= to variable = 5000 then switch off
     digitalWrite(mister, HIGH);
     
     }

     
     
  //Storm Mode//
  
  stState = digitalRead(stormTrigger);//read storm trigger
  
  if( ((millis() - lastSTDebounceTime) >= debounceDelay) && (switchValue == 0)) { //if current time- last debounce time is >=200ms then
  
  if ((stState == HIGH) && (switchValue == 0)) {
    
    switchValue=1; //n
    
    stormStartTime = millis();//set event start time to current time
  }}
  
  
  
   
    
    if (((millis()- stormStartTime) >= 100) && (switchValue==1)) {
      digitalWrite(music, LOW);//music on
      digitalWrite(fogger, LOW);//LOW is on???
      digitalWrite(shutoff, LOW);
      stormIntervalTime = millis();//set varialbe to current time    
      switchValue=switchValue+1;
   }
  
      
  
   
    
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==2)){
    digitalWrite(mister,LOW);
    digitalWrite(music,HIGH); //music back off
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;
   
  }
     
    

      if (((millis() - stormIntervalTime) >= 3000) && (switchValue==3)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue=switchValue+1;  
  }
    
    
    
    
   
     if (((millis() - stormIntervalTime) >=6000) && (switchValue==4)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    
    
   
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==5)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    
    
   
    
       if (((millis() - stormIntervalTime) >=8000) && (switchValue==6)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue=switchValue+1;  
  }
    
    
    
       
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==7)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    
    
    
    
       if (((millis() - stormIntervalTime) >=12000) && (switchValue==8)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1; 
  }
    
        
    
    
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==9)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    
    
    
    
       if (((millis() - stormIntervalTime) >=8000) && (switchValue==10)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
        
    
   
    if (((millis() - stormIntervalTime) >= 4000) && (switchValue==11)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    
    
   
    
       if (((millis() - stormIntervalTime) >=13000) && (switchValue==12)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1; 
  }
    
       
   
 
    if (((millis() - stormIntervalTime) >= 2000) && (switchValue==13)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    
    

    
       if (((millis() - stormIntervalTime) >=15000) && (switchValue==14)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
   switchValue=switchValue+1;  
  }
    
    
    
         
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==15)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
   switchValue=switchValue+1; 
    }
    
    
     
    
       if (((millis() - stormIntervalTime) >=8000) && (switchValue==16)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    
    
             
    if (((millis() - stormIntervalTime) >= 1500) && (switchValue==17)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1; 
    }
    
    
     
    
       if (((millis() - stormIntervalTime) >=14000) && (switchValue==18)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    
    
        
    if (((millis() - stormIntervalTime) >= 3000) && (switchValue==19)){
    digitalWrite(mister,HIGH); 
   stormIntervalTime = millis(); 
    switchValue=switchValue+1;  
    }
    
    
     
    
       if (((millis() - stormIntervalTime) >=18000) && (switchValue==20)){
    digitalWrite(mister,LOW);
  stormIntervalTime = millis();  
    switchValue=switchValue+1;  
  }
    
    
    
    
    
       if (((millis() - stormIntervalTime) >=2000) && (switchValue==21)){
    digitalWrite(mister,HIGH); 
    digitalWrite(fogger, HIGH);//LOW is on???
      digitalWrite(shutoff, HIGH);
  stormIntervalTime = millis();  
    switchValue = 0;
       }
    
    
    
  }

I assume you have pull-up resistors wired on these inputs and they go to ground on activation.

inMode(stormTrigger, INPUT);
pinMode(momentaryTrigger, INPUT);
pinMode(lockTrigger, INPUT);

Or you could use:

inMode(stormTrigger, INPUT_PULLUP);
pinMode(momentaryTrigger, INPUT_PULLUP);
pinMode(lockTrigger, INPUT_PULLUP);

Most recent revision. Still not functioning. Now will get to switchValue=2 before stopping

Does the value of switchValue stop at 2 or does the storm stop when its value is 2 but its value keeps increasing ?

Larry, I do. and UK HeliBob, the storm stops when value = 2, but the serial output shows the variable value continuing to increase. Its so strange.

  if ( (millis() - momentaryMisterTime) >= (demoMisterTime)) { //If current time- the time when the mister has been going is >= to variable = 5000 then switch off
    digitalWrite(mister, HIGH);

Will this not turn off the mister after 5 seconds whatever the value of switchValue ?

@UKHeliBob BRAVO!!! I added "" && (switchValue == 0) "" to that if statement so It is ignored if the switch case has been initiated. It now proceeds about a 1/3 of the way through before quitting on me. Im thinking there may be other conflicts in my code. I am just now starting to get away from using delays so its been rocky :slight_smile:
Thank you

What about

if ( (millis() - momentaryFogTime) >= (demoFoggerTime)) { //If current time- the time when the fogger has been going is >= to variable =120000 then switch off
     digitalWrite(fogger, HIGH);
     
     }

that turns off the fogger

Changed that and added another variable for the momentary events. Their if loops only work if the timing is correct & if the variable =1. By default it is 0 until the momentary switch is pressed changing it to 1.

const int fogger = 11;
const int mister = 12;
const int music = 6;
const int shutoff = 7;
const int lock = 8;
const int stormTrigger = 9;
const int momentaryTrigger = 13;
const int lockTrigger = 10;

int stState = LOW; //Initaialize Storm trigger State
int mtState = LOW; //Initialize momentary fog/mist trigger state
int ltState = LOW; //Initialize lock state :)

unsigned long lastSTDebounceTime = 0;//last time these were debounced
unsigned long lastMTDebounceTime = 0;
unsigned long lastLTDebounceTime = 0;

unsigned long debounceDelay = 200;// the debounce time

unsigned long const lockTime = 3000;//sets the time for lock to be unlocked
unsigned long  unlockStartTime =  0;//Keeps track of when unlock started

unsigned long demoFoggerTime = 120000;
unsigned long demoMisterTime = 5000;
unsigned long momentaryFogTime = 0;//Keeps track of fog start time
unsigned long momentaryMisterTime = 0; // leeps track of mister start time



unsigned long stormStartTime = 0; //tracks storm time

 unsigned long switchValue=0;
 unsigned long momentarySwitchValue=0;
 
void setup() {

  
pinMode(fogger, OUTPUT);
pinMode(mister, OUTPUT);
pinMode(music, OUTPUT);
pinMode(shutoff, OUTPUT);
pinMode(lock, OUTPUT);
pinMode(stormTrigger, INPUT);
pinMode(momentaryTrigger, INPUT);
pinMode(lockTrigger, INPUT);

digitalWrite(fogger, HIGH);
digitalWrite(mister, HIGH);
digitalWrite(music, HIGH);
digitalWrite(shutoff,HIGH);


}
  
    
    
void loop(){
  

  
   /////LOCK SKETCH////
   
   ltState = digitalRead(lockTrigger); //read locktrigger high/low and put value in ltState Variable
   
   if( (millis() - lastLTDebounceTime) >= debounceDelay) { //if current time - last debounce for trigger is > 200ms then
   
     if (ltState == HIGH){ //If Lock trigger is being pushed 
       
     digitalWrite(lock, LOW); // Turns on lock
     
     lastLTDebounceTime = millis(); //SET last Lock debounce to current time
     unlockStartTime = millis(); //SET unlock start time to current time
     
     }}
     
     if ( (millis() - unlockStartTime) >= lockTime) { //If current time- the time when the lock opened is >= to variable =3000 then close
     digitalWrite(lock, HIGH);
     
     }
     
     
     
     
     ////Mister/Fogger Demo Sketch///
     
     mtState = digitalRead(momentaryTrigger); //Read momentary trigger
     
     if( (millis() - lastMTDebounceTime) >= debounceDelay) { //if current time- last debounce for momentary trigger is >= 200ms then
     
     
     if ((mtState == HIGH) && (switchValue == 0)) { //if momentary switch is on and the storm is NOT ocurring
     
     digitalWrite(fogger, LOW); 
     digitalWrite(mister, LOW);
     
     lastMTDebounceTime = millis();  //set mt trigger debounce time to current
     momentaryFogTime = millis(); //set fogger time
     momentaryMisterTime = millis();// set mister Time
     momentarySwitchValue=1;
     }}
     
     if ( ((millis() - momentaryFogTime) >= (demoFoggerTime)) && (switchValue==0) && (momentarySwitchValue=1)) { //If current time- the time when the fogger has been going is >= to variable =120000 then switch off
     digitalWrite(fogger, HIGH);
     momentarySwitchValue=0;
     }
     
     if ( ((millis() - momentaryMisterTime) >= (demoMisterTime)) && (switchValue==0) && (momentarySwitchValue=1)) { //If current time- the time when the mister has been going is >= to variable = 5000 then switch off
     digitalWrite(mister, HIGH);
     
     }

     
     
  //Storm Mode//
  
  stState = digitalRead(stormTrigger);//read storm trigger
  
  if( ((millis() - lastSTDebounceTime) >= debounceDelay) && (switchValue == 0)) { //if current time- last debounce time is >=200ms then
  
  if ((stState == HIGH) && (switchValue == 0)) {
    
    switchValue=1; //n
    
    stormStartTime = millis();//set event start time to current time
  }}
  
  
  
   
      if(switchValue==1) {
    if ((millis()- stormStartTime) >= 1000l) {
  
      digitalWrite(music, LOW);//music on
      digitalWrite(fogger, LOW);//LOW is on???
      digitalWrite(shutoff, LOW);
      
      switchValue=switchValue+1;
   }}
  
      
  

    if(switchValue==2){
    if ((millis() - stormStartTime) >= 4000l){
    
    digitalWrite(mister,LOW);
    digitalWrite(music,HIGH); //music back off
    
    switchValue=switchValue+1;

  }} 
    
if (switchValue==3){
      if ((millis() - stormStartTime) >= 7000l){ 
     
    digitalWrite(mister,HIGH); 
    
   switchValue=switchValue+1;  
  }}
    
    
    
    
   if (switchValue==4){
     if ((millis() - stormStartTime) >=13000l){ 
     
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1;  
  }}
    
    
    
    if (switchValue==5){
    if ((millis() - stormStartTime) >= 16000l){ 
    
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1; 
    }}
    
    
   
      if (switchValue==6){
       if ((millis() - stormStartTime) >=24000l){ 
       
    digitalWrite(mister,LOW);
    
   switchValue=switchValue+1;  
  }}
    
    
    if (switchValue==7){
    if ((millis() - stormStartTime) >= 27000l){ 
 
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1; 
    }}
    
    
    
     if (switchValue==8){
       if ((millis() - stormStartTime) >=39000l){ 
    
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1; 
  }}
    
        
    
      if (switchValue==9){
    if ((millis() - stormStartTime) >= 42000l){
    
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1;  
    }}
    
    
    
    if (switchValue==10){
       if ((millis() - stormStartTime) >=50000l){ 
       
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1;  
       }}
        
    
   if (switchValue==11){
    if ((millis() - stormStartTime) >= 54000l){
    
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1;  
    }}
    
    
   
      if (switchValue==12){
       if ((millis() - stormStartTime) >= 67000l){ 
    
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1; 
  }}
    
       
   
     if (switchValue==13){
    if ((millis() - stormStartTime) >= 69000l){ 
    
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1;  
    }}
    
    

     if (switchValue==14){
       if ((millis() - stormStartTime) >=84000l){ 
       
    digitalWrite(mister,LOW);
    
   switchValue=switchValue+1;  
  }}
    
    
    
        if (switchValue==15){  
    if ((millis() - stormStartTime) >= 87000l){ 
  
    digitalWrite(mister,HIGH); 
    
   switchValue=switchValue+1; 
    }}
    
    
     
     if (switchValue==16){
       if ((millis() - stormStartTime) >=95000l){
    
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1;  
  }}
    
    
    
                if (switchValue==17){
    if ((millis() - stormStartTime) >= 96500l){
    
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1; 
    }}
    
    
     
    if (switchValue==18){
       if ((millis() - stormStartTime) >=110500l){ 
 
    digitalWrite(mister,LOW);
    
    switchValue=switchValue+1;  
  }}
    
    
    
         if (switchValue==19){
    if ((millis() - stormStartTime) >= 113500l){
   
    digitalWrite(mister,HIGH); 
    
    switchValue=switchValue+1;  
    }}
    
   
    
    
    if (switchValue==20){
       if ((millis() - stormStartTime) >=18000l){
      
     
    digitalWrite(fogger, HIGH);//LOW is on???
      digitalWrite(shutoff, HIGH);
    
    switchValue = 0;
       
       }}}

Works flawlessly now! thanks UKHeliBob! I told myself I would dive into arduino over Christmas break and you have certainly made that easier on me. Its strange thinking in loops rather than linearly.

You should start to think about using debugging techniques to prove things are what you think they are.
Serial.print() is your friend.
The Arduino does what you tell it to :wink:

Good for you!

Larry D I agree!
BTW, this sketch is for a tegu lizard enclosure

Storm mode running delays from months ago.
http://videobam.com/eKCrz#.U39EoUu6O9Q.linkMy