Counting a loop

This timing is done by a delay

Bad idea.

Get rid of all delay()s. Notice when things of interest happen, as in the blink without delay example.

the delay is important,

Important and necessary are not the same thing. You do NOT need a delay on every pass through loop().

      if ( 50 < pos < 130 )  { // depends on deadbolt: switch 90 and 180 in the declartions of the poisitions above ^^^ before void setup(){}

if pos is less than 50, the result is true. true IS less than 130. That is NOT how to check a range. And, the comment is rubbish.