Code problems

Good evening,
i have obstacles using this code,
the codes doesn’t obey the rules of it’s code, when we press any number it denies the access but yet the servo motor works and when we press the keypad numbers it does not show the same number it uses different numbers. therefore, i want to know what are the possible solutions and how can we make the servo motor rotate only if the password is right and when we press other passwords it doesn’t move?

Code:
*/

#include <Password.h>
#include <Keypad.h>
#include <Servo.h>
#pragma GCC diagnostic ignored “-Wwrite-strings”
Servo myservo; //declare servo
Password password = Password( “5523” );

const byte ROWS = 4; // declare the rows of the keypad
const byte COLS = 3; // declare the columns of the keypad

// Define the Keymap

char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’*’,‘0’,’#’}
};

byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.
byte colPins[COLS] = {6,7,8}; // Connect keypad’s pins to these Arduino pins.

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

void setup(){
Serial.begin(9600);
myservo.write(0);
pinMode(11, OUTPUT); //The green led is set as an output.
pinMode(12, OUTPUT); //The red led is set as an output.
myservo.attach(13); //The servo is connected to the digital pin 13.
keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad

}

void loop(){
keypad.getKey();
myservo.write(180); //why? what happens if you comment it? ###########################
//delay(5);
}

void keypadEvent(KeypadEvent eKey){
// When the KeyPad will be pressed, the results will appear on the serial monitor.
switch (keypad.getState()){
case PRESSED:
Serial.print("Enter: ");
Serial.println(eKey);
delay(10);

switch (eKey){
case ‘*’:
checkPassword(); // Will check the password.
delay(1); // Delay used for stability.
break;

case ‘#’:
password.reset(); //Will reset the password
delay(1); // Delay used for stability.
break;

default:
password.append(eKey); //Append any keypress that is not a ‘#’ nor a ‘*’.
delay(1);
}
}
}
void checkPassword(){

if (password.evaluate()){ //If the combination inserted is equal to the combination saved, the servo’ll rotate.
Serial.println(“Accepted”);
//delay(5000);
delay(10);
myservo.write(50); //was 140
delay(5000);

digitalWrite(11, HIGH); //Turn the green led on.
delay(500); //Wait 5 seconds.
digitalWrite(11, LOW); //Turn the green led off.

//break; // remove if trial did not work #####################try#####################
}
//break; // remove if trial did not work ##########################################
else{ //If the combination inserted isn’t equal to the combination saved, the servo will not rotate.
//delay(5000); delays response
Serial.println(“denied”);
delay(10);
//delay(5000);
myservo.write(20); // was 50
digitalWrite(12, HIGH); //Turn the green led on.
delay(5000); //Wait 5 seconds. was 500 ///
digitalWrite(12, LOW); //Turn the green led off.

}
}

Thank you.

please reply asap

First, take the time to read Nick Gammon's posts at the top of this Forum on the proper way to post here, especially the use of code tags when posting source code. Second, before you post code, place the cursor in the IDE's edit window and press Ctrl-T, which reformats your code in a common C style. Third, when you call keypad.getKey(), wouldn't it be useful to store the value returned from the call in a variable rather than having it rattle around in the ether? Finally, spend a little time looking up the use of the switch-case statement block and the role that break and default play in that structure.