(Fixed)Issues with If Statements

I am trying to write a function that will do something if a variables are certain values

eg.

if x = 1
do ab
else do ba

if y = 1
do cd
else do dc

if z = 1
do ef
else do fe

the problem is that if i set it up like that, it only checks if x = 1 and then if it does, it doesn't also check y = 1.

Here is the code

void blinker(){
  long timer = millis();

  if (zone1state == BLINK){
    if(timer - oldtimer > interval) {
      oldtimer = timer;   
      if (zone1s == LOW){
        zone1s = HIGH;
        //Serial.print(zone1s);
      }
      else {
        zone1s = LOW;
      } 
      digitalWrite(zoneL1, zone1s); 
    }  
  }
  else 
    digitalWrite(zoneL1, (zone1state == ISON) ? LOW : HIGH);
  

if (zone2state == BLINK){
    if(timer - oldtimer > interval) {
      oldtimer = timer;   
      if (zone2s == LOW){
        zone2s = HIGH;
        //Serial.print(zone1s);
      }
      else {
        zone2s = LOW;
      } 
      digitalWrite(zoneL2, zone2s); 
    }  
  }
  else 
    digitalWrite(zoneL2, (zone2state == ISON) ? LOW : HIGH);
  
  
  if (zone3state == BLINK){
    if(timer - oldtimer > interval) {
      oldtimer = timer;   
      if (zone3s == LOW){
        zone3s = HIGH;
        //Serial.print(zone1s);
      }
      else {
        zone3s = LOW;
      } 
      digitalWrite(zoneL3, zone3s); 
    }  
  }
  else 
    digitalWrite(zoneL3, (zone3state == ISON) ? LOW : HIGH);
  
 
  if (zone4state == BLINK){
    if(timer - oldtimer > interval) {
      oldtimer = timer;   
      if (zone4s == LOW){
        zone4s = HIGH;
        //Serial.print(zone1s);
      }
      else {
        zone4s = LOW;
      } 
      digitalWrite(zoneL4, zone4s); 
    }  
  }
  else 
    digitalWrite(zoneL4, (zone4state == ISON) ? LOW : HIGH);
  
}

If i press zone 4, it will blink, but then, if i press zone 1, zone 4's light will stay on, and zone 1 will blink. If i press zone 4 again, nothing happens (zone 4 is still on and zone 1 blinks).

If i press zone 1, it will blink, but then in i press zone 4, zone 1 keeps blinking, and zone 4 doesn't light up.

Doesn't compile...

sketch_sep13a.ino: In function ‘void blinker()’:
sketch_sep13a:4: error: ‘zone1state’ was not declared in this scope
sketch_sep13a:4: error: ‘BLINK’ was not declared in this scope
sketch_sep13a:5: error: ‘oldtimer’ was not declared in this scope
sketch_sep13a:5: error: ‘interval’ was not declared in this scope
sketch_sep13a:7: error: ‘zone1s’ was not declared in this scope
sketch_sep13a:14: error: ‘zoneL1’ was not declared in this scope
sketch_sep13a:14: error: ‘zone1s’ was not declared in this scope
sketch_sep13a:18: error: ‘zoneL1’ was not declared in this scope
sketch_sep13a:18: error: ‘ISON’ was not declared in this scope
sketch_sep13a:21: error: ‘zone2state’ was not declared in this scope
sketch_sep13a:21: error: ‘BLINK’ was not declared in this scope
sketch_sep13a:22: error: ‘oldtimer’ was not declared in this scope
sketch_sep13a:22: error: ‘interval’ was not declared in this scope
sketch_sep13a:24: error: ‘zone2s’ was not declared in this scope
sketch_sep13a:31: error: ‘zoneL2’ was not declared in this scope
sketch_sep13a:31: error: ‘zone2s’ was not declared in this scope
sketch_sep13a:35: error: ‘zoneL2’ was not declared in this scope
sketch_sep13a:35: error: ‘ISON’ was not declared in this scope
sketch_sep13a:38: error: ‘zone3state’ was not declared in this scope
sketch_sep13a:38: error: ‘BLINK’ was not declared in this scope
sketch_sep13a:39: error: ‘oldtimer’ was not declared in this scope
sketch_sep13a:39: error: ‘interval’ was not declared in this scope
sketch_sep13a:41: error: ‘zone3s’ was not declared in this scope
sketch_sep13a:48: error: ‘zoneL3’ was not declared in this scope
sketch_sep13a:48: error: ‘zone3s’ was not declared in this scope
sketch_sep13a:52: error: ‘zoneL3’ was not declared in this scope
sketch_sep13a:52: error: ‘ISON’ was not declared in this scope
sketch_sep13a:55: error: ‘zone4state’ was not declared in this scope
sketch_sep13a:55: error: ‘BLINK’ was not declared in this scope
sketch_sep13a:56: error: ‘oldtimer’ was not declared in this scope
sketch_sep13a:56: error: ‘interval’ was not declared in this scope
sketch_sep13a:58: error: ‘zone4s’ was not declared in this scope
sketch_sep13a:65: error: ‘zoneL4’ was not declared in this scope
sketch_sep13a:65: error: ‘zone4s’ was not declared in this scope
sketch_sep13a:69: error: ‘zoneL4’ was not declared in this scope
sketch_sep13a:69: error: ‘ISON’ was not declared in this scope

That's only part of your code. Please post all of it.

I wonder if there is a problem using the same variables for the timing of all the zones?

This

if (zone1s == LOW){
        zone1s = HIGH;
        //Serial.print(zone1s);
      }
      else {
        zone1s = LOW;
      }

can be reduced to this

zone1s = ! zone1s

...R

:roll_eyes:

Yes, guys.

Thanks for your attention, but Robin2 hit the nail on the head.

if(timer - oldtimer > interval) never was true. I made the topic too soon. My apologies.

Thanks for the tip about the optimization, Robin. Also, your funny MarkT (but what your saying is true, i should have posted all my code. I assumed incorrectly it was something wrong with the code, not the logic at first.