I would like to say that this segment of my code is based on reply 23 from this thread. I've made some changes but the else/else ifs took their initial form there.
PaulS:
If FrontDoorLED is not OFF, what else could it be besides ON?
It could be flashing (FLASH). Are you saying I need to cater for this state? It seems to work well without this, but perhaps I haven't thoroughly tested if a third button press is ignored as it should be.
PaulS:
Then, we encounter FrontDoorRoutine. No clue what this is supposed to signify
I' m having real trouble thinking of a different name, as this is a variable used to see whether the LED is currently off, on or flashing. I've changed it to FrontDoorLEDStateManager but I doubt you'll like this state any better!
PaulS:
if it is OFF (whatever off means)
This confused me as well. I don't see how it can work to set an int to ON, OFF or FLASH - but this appears to be done using 'enum'.
PaulS:
There is, in the if(FrontDoorLED == OFF) and else if(FrontDoorLED == ON) blocks, the same code. That code should be moved outside the if/else if blocks.
With respect, it's not exactly the same, and I don't see how things could continue to work as they do if I do as you suggest. However, I am likely wrong.
PaulS:
The else if should not be an else if. It should be simply an else.
Again, with respect, not sure about this. There are three conditions I want to cater for: routine not on, routine on and routine flashing. Surely if I make it an 'else', I reduce my ability to check to two conditions, off and on. I wouldn't be able to deal with a situation whereby the button is pressed and the routine is in 'flash' mode.
PaulS:
The Servo.write() methods starts the servo moving, and returns.
Aha, so telling the servo to move to position 180 will in fact cause the servo to do that, and then return to its dormant position once it reaches 180? In that case I don't need to 'tell' the servo to return...
THANK YOU PAUL!