door lock with Arduino and a servo

how do I add that he just moves on singnal into arduinon?

#include <Servo.h>
Servo myservo;
int pos = 180;
void setup() {
 myservo.attach(9);
  myservo.write(0);
    delay(20000);
    myservo.write(180); // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}