Been trying to make this safe have two inputs but the rfid reader isnt working

rfid wont work dont know y

#include <ESP32Servo.h>
#include <Password.h>
#include <Keypad.h>
#include <SPI.h>
#include <MFRC522.h>
 
#define SS_PIN 2
#define RST_PIN 4
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 
Servo myservo;
Password password = Password( "2692" ); // Set password as 
const byte ROWS = 4; // set four rows
const byte COLS = 4; // set four columns
char keys[ROWS][COLS] = { // Define the keymap
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {36, 39, 34, 35}; 
byte colPins[COLS] = {32, 33, 25, 26};
// Create the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins,
                        ROWS, COLS );
void setup() {
  Serial.begin(9600);
  delay(200);

  pinMode(13, OUTPUT); // Set green LED as output
  pinMode(12, OUTPUT); // Set red LED as output
  myservo.attach(4); // Pin connected to servo
  myservo.write(0);
  keypad.addEventListener(keypadEvent); // Add an event listener to
  // detect keypresses
     SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
   Serial.println();
  Serial.println("Approximate your card to the reader...");
 
}
void loop() {
  keypad.getKey();
}
void keypadEvent(KeypadEvent eKey) {
  switch (keypad.getState()) {
    case PRESSED:
      Serial.print("Pressed: ");
      Serial.println(eKey);
      switch (eKey) {
        case '*': checkPassword(); break;
        case '#': password.reset(); break;
        default: password.append(eKey);
      }
  }
 
}
void loop1()
{
    // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "B5 80 02 75") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
     myservo.write(90); // Move servo arm 90 degrees
    digitalWrite(13, HIGH); // Turn on green LED
    delay(500); // Wait 5 seconds
    digitalWrite(13, LOW); // Turn off green LED
     password.reset();
   
  }
 
 else   {
    Serial.println(" Access denied");
   myservo.write(0);
    digitalWrite(12, HIGH); // Turn on red LED
    delay(500); // Wait 5 seconds
    digitalWrite(12, LOW); // Turn off red LED
  }
}
void checkPassword() {
  if (password.evaluate() ) {
    Serial.println("Success"); // If the password is correct...
    myservo.write(90); // Move servo arm 90 degrees
    digitalWrite(13, HIGH); // Turn on green LED
    delay(500); // Wait 5 seconds
    digitalWrite(13, LOW); // Turn off green LED
    password.reset();  } else {
    Serial.println("Wrong"); // If the password is incorrect...
    myservo.write(0);
    digitalWrite(12, HIGH); // Turn on red LED
    delay(500); // Wait 5 seconds
    digitalWrite(12, LOW); // Turn off red LED
  }
}

Welcome to the forum

Most of your code is in the loop1() function but you never call that function

what do you mean
how do i do that

I mean that just because you put a function in a sketch the code in that function will not run unless you tell it to

The code in the setup() function will automatically run once when the sketch runs and the loop() function will automatically run over and over again unless you have done something to stop it. Other functions, such as checkPassword() only run when they are called, like this

case '*': checkPassword(); break;

At the point in the sketch where you would like the code in the loop1() function to run you could do

loop1();

Note, however, that just because its name includes the word "loop" does not mean that it will run over and over again. You have to call it each time that you want it to run

Where did you get this code from ?

i made it but im not super great at knowing the code

how would i keep calling it

I have not looked at the code in detail but remember what I said about the loop() function being automatically called repeatedly ? So, if you were to call loop1() as the last line of loop() it would be called repeatedly

how do i do that
can u give me the code to do it

Insert this

loop1();

as the last line of the loop() function, but note that I have no idea whether your code will do what you want

@dampbird-101 Welcome to the forum and lurning how to program stuff by OOP, in your loop function, you have to call your function to check if your password or here in your case the rfid used is that one registered. Like @UKHeliBob mentioned you´ll have to call it, otherwise its a sleeping function.

void loop(){
// Call the function 
loop1();
// every 0.5 second make the same loop
delay(500);
}

Have fun in programming :wink:

But void loop() also contains this user-interface, so the keypad will seem unresponsive...

void loop() {
  keypad.getKey();
}

After you @dampbird-101 get the loop1() into loop(), then you might want to ask about how to change the delay(500) into a non-blocking timer.

@xfpd Yeah indeed, you can delete the delay or change it into a smaller one, f.e. delay(50);
I only wrote it to test :blush: