if (FrontDoorLED == OFF)
{
}
else if (FrontDoorLED == ON)
{
If FrontDoorLED is not OFF, what else could it be besides ON?
Some of your names still leave a bit to be desired. DoorBellTriggered is a great name. It implies that something might have happened to get us to the point that we need to do something. Then, we encounter FrontDoorRoutine. No clue what this is supposed to signify, but if it is OFF (whatever off means), we do something (that results in the servo being moved one way). If not, we move the servo the other way.
DoorBellTriggered is compared to 1 and set to 0. FrontDoorRoutine is compared to ON and set to OFF. The inconsistencies make the code hard to follow. The snippet makes it impossible to tell what type the twp variables are, or what type and value ON and OFF are and have.
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.
I seem to have lost a closing bracket in my newer code after the else if routine. Surely this is adversely affecting how/when/if the else routine is operating.
The else if should not be an else if. It should be simply an else. Yes, it does look like you are doing things differently. The random indents make it impossible to determine what that is, though.
How should a servo operate?
- Should it:
a) move to a position and stay there
or
b) should it move back when it's reached that position?- If it's told to move to position 180 and then in the very next line told to move to position 0, should it complete the first move before doing the next, or does having two instructions so close together effectively cancel the first move out?
The Servo.write() methods starts the servo moving, and returns. If you issue another one before the servo has had time to move to the position defined on the first call, it will stop trying to get there, and go to the position defined in the second call. You need to add a delay() (or the millis() equivalent) between the two calls.