Counting a loop

Robin2:
I would break your code into two functions - a bit like this

void rfid()  {

if (lockPos == locked) {
      lockPos = unlocked;
  }
  else {
        lockPos = locked;
  }
)

void moveLock() {
   deadlock.write(lockPos);
}





...R

Thank you @joshuabardwell! I call the moveLock() in the loop so that it is constantly writing to the servo motor. This also works for the sleep mode that I was making. No interference from writing to the servo when a card is within range.

Thank you to @Robin2, @PaulS, and @joshuabardwell for the great support and helping hand. Being my first time using a forum, and first time taking on a microcontroller project, thank you again!