how to enable and disable signal coming from sensor using keypad

yes sir..i want to enable the signal if the password input by a keypad is valid....else it disable the signal...

here is my code in keypad:

#include <Password.h>
#include <LiquidCrystal.h>
#include <Keypad.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Password password = Password( "4567" );
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3',},
  {'4','5','6',},
  {'7','8','9',},
  {'*','0',' ',}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10, 13, 14}; //connect to the column pinouts of the keypad


// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



void setup(){
                                           
lcd.begin(16, 2);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
keypad.setDebounceTime(250);
}

void loop(){
char key = keypad.getKey();
  if (key){
   lcd.setCursor(0, 0);
    lcd.print('*'); //display * when input the password
   
  }}



//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
switch (eKey){
case ' ': guessPassword(); break;

default:
password.append(eKey);
}
}}

void guessPassword(){
if (password.evaluate()){
delay(500);
lcd.setCursor(0, 1);
lcd.print("VALID PASSWORD"); //
password.reset(); //resets password after correct entry
delay(1000);
lcd.clear();
lcd.print("ACTIVATED!");
delay(2000);
lcd.clear();

}

else{
lcd.setCursor(0, 1);
lcd.print("INVALID PASSWORD");
password.reset(); //resets password after INCORRECT entry
delay(5000);
lcd.clear();
lcd.print("TRY AGAIN!");
delay(2000);
lcd.clear();
}
}

PIR Code + servo:

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 

int pos = 0;                                                      // Variable to store the servo position in degrees
int pinPIRleft = 15;                                               // left infrared sensor, digital pin	                                          
int pinPIRright = 16;                                              // right sensor, digital pin                                         

void setup() {
  pinMode(pinPIRleft, INPUT);                                    // set sensors as inputs
  pinMode(pinPIRright, INPUT);
  myservo.attach(17);    
}
 
void loop(){
  if (((pos < 180) && (digitalRead(pinPIRright) == HIGH)&& (digitalRead(pinPIRleft) == HIGH))){      //PIR detected motion
     pos += 1;                                                   // increment servo degrees by +1
      myservo.write(pos);                                         // write the position to the servo
    }
    else {}// do nothing
  
    if  ((pos >= 1) && (digitalRead(pinPIRleft) == LOW) && (digitalRead(pinPIRright) == LOW)) {    //no motion detected
      pos -= 1;
      myservo.write(pos);
    }
    else{}
  
}

Moderator edit: CODE TAGS AGAIN.

how can i combine the codes of keypad to PIR and servo..my project is when u input password then if it is valid..thats the time that the PIR will activate or on...else PIR will ignore signals...and when i enter again the password the PIR will off..