Robin2:
The logic of the system would be much easier to follow if the different activities are put into their own functions
Changed it to this:
void rfid() {
if ( deadbolt.read() == locked ) {
deadbolt.write(unlocked);
pos = unlocked;
return;
}
else if ( deadbolt.read() == unlocked ) {
deadbolt.write(locked);
pos = locked
return;
}
Now a new function will be called when a card is within range and the position of the servo will be verified. I put a variable named 'pos' in before setup() to store the value of servo.write() .