Toggling a push button within a control program

the variable you named "previous" is never changed anywhere in your code!
the purpose of this variable is to store the last button state so you can detect a change
in your button state. without up dating the "previous" variable you cant detect a change!

also since the delay(500) is in your loop section you are making the button detection wait too.
this will make your button very annoyingly insensitive to the user.

a more reasonable wait to help with bounce would be about 5.

please get into the habit of allways using brackets after your "if" statements.
this way you can use nested "if" statements and multiple lines after an "if".

if you are not familiar with the exclamation mark operator in my code below... it means opposite or NOT equal

here is a basic example to detect a simple button push and create a section that happens less frequently for your other stuff. hopefully you can take it from there.

  int sensorTimer;

void loop() {


  reading = digitalRead(dswPin);   /// door lock open / close
  if(reading!=previous){// check for change
    
        if(reading==LOW){// check for down
         state=!state; // set state to opposite
         Serial.println("button was pushed");
         digitalWrite(ledPin, state);
         digitalWrite (outPin, state);
         }
     previous=reading;
     }
 
 sensorTimer++;
 if(sensorTimer>100){sensorTimer=0;

 // everything here will happen every 500 miliseconds
 // so this is where you do your other stuff that happens 
 // with a longer delay !!!!!
 
 }
  delay(5);// makes main loop happen every 5 milliseconds 
}