PIR (Motion Sensor) + RFID Doorlock

Hi folks, I am done with my programming skills and it is still not working properly therefore it is time to ask the experts.

My project is pretty simple:

I want to control my door opening with two sensors:

Outside will use a RFID module (RC522) to identify the card

inside will use a Motion Sensor (PIR am312) to see when I approach and release the door.

They do work individually, but together don't.

Maybe I am missing the programming logic here on the "IFs/else"?

Any help will be much appreciated, here is the code:

int pinopir = 3;  //Pin PIR
int acionamento;  //sensor variable
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

void setup()
{
  pinMode(pinopir, INPUT);   //Define pino sensor input
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600); 
  pinMode(2, OUTPUT);
  Serial.begin(9600);   // start a serial
  SPI.begin();      // start  SPI bus
  mfrc522.PCD_Init();   // start MFRC522
}

void loop()
{
 acionamento = digitalRead(pinopir); //read sensor PIR
 if (acionamento == LOW)  
 {
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
 }

  // Procura por cartao RFID
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }

 else 
 {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.println("Ola FILIPEFLOP !");
  digitalWrite(2, HIGH); // ativa rele, open door
  delay(3000);           // wait 3 sec
  digitalWrite(2, LOW);  // desativa rele, close door
 }
  
  // Seleciona o cartao RFID
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Mostra UID na serial
  Serial.print("UID da tag :");
  String conteudo= "";
  byte letra;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Mensagem : ");
  conteudo.toUpperCase();
 
  if (conteudo.substring(1) == "74 A9 4E 43") //UID 1 - Cartao
  {
    Serial.println("Ola Cartao 1 !");
    Serial.println();
    digitalWrite(2, HIGH); // ativa rele, abre a trava solenoide
    delay(2000);           // espera 3 segundos
    digitalWrite(2, LOW);  // desativa rele, fecha a trava solenoide
  }  
    if (conteudo.substring(1) == "A7 BA 80 26") //UID 2 - Cartao
  {
    Serial.println("Ola Carteo 2 !");
    Serial.println();
    digitalWrite(2, HIGH); // ativa rele, abre a trava solenoide
    delay(2000);           // espera 3 segundos
    digitalWrite(2, LOW);  // desativa rele, fecha a trava solenoide
  }  
  if (conteudo.substring(1) == "4D 6C B5 63") //UID 3 - Cartao
  {
    Serial.println("Ola Cartao 3 !");
    Serial.println();
    digitalWrite(2, HIGH); // ativa rele, abre a trava solenoide
    delay(2000);           // espera 3 segundos
    digitalWrite(2, LOW);  // desativa rele, fecha a trava solenoide
  }  
    if (conteudo.substring(1) == "76 B5 64 1F") //UID 4 - Cartao
  {
    Serial.println("Ola Cartao 4 !");
    Serial.println();
    digitalWrite(2, HIGH); // ativa rele, abre a trava solenoide
    delay(2000);           // espera 3 segundos
    digitalWrite(2, LOW);  // desativa rele, fecha a trava solenoide
  }  
}
  [color=red]Serial.begin(9600); [/color]
  pinMode(2, OUTPUT);
  [color=red]Serial.begin(9600);   // start a serial[/color]

do you need to start it twice?

void loop()
{
  acionamento = digitalRead(pinopir); //read sensor PIR
  if (acionamento == LOW)
  {
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  }
  // Procura por cartao RFID
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }

You read the state of the PIR pin but all you do is if it is LOW you turn off the LED then if no RFID card is present you start the loop() function again

How is the the detection of a person by the PIR going to open the door ?