nested else if's using Millis timer

I am trying to make a simpler brake light program that when either the front or back brakes are used it just turns on the light but when both are used it flashes.

In setup BrakemillisPrev = 0; is set.

Basically It doesnt flash as expected.....I must be nesting somewhere in correctly?

void brakes() {
  unsigned long BrakemillisNow;
  Fbrakestat = digitalRead (FbrakeSw);
  Rbrakestat = digitalRead (RbrakeSw);
  int brakelightstat = LOW;
  if (Fbrakestat == LOW || Rbrakestat == LOW) {
    digitalWrite (brakeLightout, HIGH);
  } else if  ((Fbrakestat == LOW) && (Rbrakestat == LOW)) {
    BrakemillisNow = millis();
    (BrakemillisNow - BrakemillisPrev >= Brakeperiod);
    BrakemillisPrev = BrakemillisNow;
    if (brakelightstat == LOW) {
      brakelightstat = HIGH;
    } else {
      brakelightstat = LOW;
    }
    digitalWrite (brakeLightout, brakelightstat);
  }
  else {
    digitalWrite (brakeLightout, LOW);
  }

}

Your if is the wrong way round. If both brakes are in use then front OR back is true too. Check the AND case first.

I'm checking the && now first and added a serial.print test to see the && condition is met which it is but it still doesnt seem to flash. Is my period check correct?

void brakes() {
  unsigned long BrakemillisNow;
  Fbrakestat = digitalRead (FbrakeSw);
  Rbrakestat = digitalRead (RbrakeSw);
  int brakelightstat = LOW;
  if ((Fbrakestat == LOW) && (Rbrakestat == LOW)) {
    BrakemillisNow = millis();
    if (BrakemillisNow - BrakemillisPrev >= Brakeperiod){
    Serial.println ("brakes period");
    BrakemillisPrev = BrakemillisNow;
    if (brakelightstat == LOW) {
      brakelightstat = HIGH;
    } else {
      brakelightstat = LOW;
    }
    digitalWrite (brakeLightout, brakelightstat);
    }

  } else if  (Fbrakestat == LOW || Rbrakestat == LOW) {
    digitalWrite (brakeLightout, HIGH);

  }  else {
    digitalWrite (brakeLightout, LOW);
  }
}

Oooops semicolon?

 if (BrakemillisNow - BrakemillisPrev >= Brakeperiod);{

Check you if (....) { .... } else { .... } syntax.

Also this...

 int brakelightstat = LOW;

Declares a new variable, and always sets it to low each time through loop.

If you need a variable to retain its value, declare it as global. Then do not redeclare it using the “int” keyword again.

Of course ....thanks....Its part of a much bigger program and I think I went a bit snow blind!!

int brakelightstat = LOW;

Now a global and all good.

Thanks guys.