How can I get my code to wait for me to scan my second RFID?

Is there a way for me to pause my code in the middle of the two if statements so I can scan the second RFID so the code can continue on to the second if statement with the information from the second RFID? I want to scan two RFIDs within the duration of the code.

// Using Arduino Uno and RFIDs RC522
#include <require_cpp11.h>
#include <MFRC522.h>
#include <deprecated.h>
#include <MFRC522Extended.h>

#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
int count = 0; 
int greenLED = 5;
int redLED = 6;
int yellowLED = 7;

void setup()
{
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);

  
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println();
 
}
void loop()
{
  // 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();
  int count = 0;
  
  if (content.substring(1) == "89 E7 75 47") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access"); 
    Serial.println();
    digitalWrite(yellowLED, HIGH);
    delay(1000);
    digitalWrite(yellowLED, LOW);

  count = count + 1;
  }
 else   {
    Serial.println(" Access denied");
    Serial.println();
    digitalWrite(redLED, HIGH);
    delay(1000);
    digitalWrite(redLED, LOW);


if (content.substring(2) == "F9 9A 76 47")
  {
    Serial.println("Authorized access"); 
    Serial.println();
    digitalWrite(yellowLED, HIGH);
    delay(1000);
    digitalWrite(yellowLED, LOW); 
    count = count + 1;
  }
 else   {
    Serial.println(" Access denied");
    Serial.println();
    digitalWrite(redLED, HIGH);
    delay(1000);
    digitalWrite(redLED, LOW);
  }

if (count == 2 ) {
    Serial.println(" Done");
    Serial.println();
    digitalWrite(greenLED, HIGH);
    delay(3000);
    digitalWrite(greenLED, LOW);

}

}
}

You can use a variable to keep track what needs to be done. The basic framework below.

void loop()
{
  static byte state = 1;

  switch (state)
  {
    case 1:
      // read card 1
      ...
      ...
      // indicate that we now can read card 2
      state = 2;
      break;
case 2:
      // read card 1
      ...
      ...
      // indicate that both cards are read
      state = 3;
      break;
    case 3:
      // do whatever you want to do when both cards are read
      ...
      ...
      // indicate that we start all over again
      state = 1;
      break;
  }

}

Is there a way for me to pause my code in the middle of the two if statements so I can scan the second RFID so the code can continue on to the second if statement with the information from the second RFID?

Here is the first if statement:

  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }

It says "If there is not a card present, forget it. Loop isn't doing anything".

Here is the second if statement:

  if ( ! mfrc522.PICC_ReadCardSerial()) {

It tries to read the card that is present, and if not successful, it, too, tells loop to forget trying to do anything.

I've told you that you need to re-write that piss-poor example code. But, you refuse to do that.

So, there is no way in hell that your code will EVER work the way you want, no matter how many more threads you start.

OK, I feel like this time I understand wath you want to do (maybe I'm wrong).

As @PaulS already said, seems to me that your original code is not really the best possible.

So, I tried to rearrange things to do what follows:

  1. If you read the first card, yellow led blink and goto 2), otherwise red led blink, and stay to 1)

  2. If you read the second card, yellow led blink and goto 3), otherwise red led blink and goto 1)

  3. done, green led blink, go to 1)

Here the full worked code:

// Using Arduino Uno and RFIDs RC522
#include <require_cpp11.h>
#include <MFRC522.h>
#include <deprecated.h>
#include <MFRC522Extended.h>

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

int greenLED = 5;
int redLED = 6;
int yellowLED = 7;

void setup()
{
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println(); 
}

#define NO_CARD 0
#define CARD_1  1
#define CARD_2  2
#define OTHER_CARDS 3

int readCard()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {    
    return NO_CARD;
  }
  
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {  
    return NO_CARD;
  }
  
  //Show UID on serial monitor
 
  Serial.print("UID tag :");
  String content= "";
  
  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) == "89 E7 75 47") //change here the UID of the card/cards that you want to give access
    return CARD_1;

  if (content.substring(1) == "F9 9A 76 47")
    return CARD_2;

  return OTHER_CARDS;    
}

int blockingReadCard()
{
   int cardId = NO_CARD;
  
  do
  {
    delay(10);
    cardId = readCard();  
    
  } while( cardId == NO_CARD );

  return cardId;
}

bool readFirstCard()
{
  int cardId = blockingReadCard();
  
  if ( cardId == CARD_1)
  {
    Serial.println("Authorized access"); 
    Serial.println();
    digitalWrite(yellowLED, HIGH);
    delay(1000);
    digitalWrite(yellowLED, LOW);

    return true;
  }

  Serial.println(" Access denied");
  Serial.println();
  digitalWrite(redLED, HIGH);
  delay(1000);
  digitalWrite(redLED, LOW);

  return false;  
}

bool readSecondCard()
{
  int cardId = blockingReadCard();
  
  if ( cardId == CARD_2)
  {
    Serial.println("Authorized access"); 
    Serial.println();
    digitalWrite(yellowLED, HIGH);
    delay(1000);
    digitalWrite(yellowLED, LOW);

    return true;
  }

  Serial.println(" Access denied");
  Serial.println();
  digitalWrite(redLED, HIGH);
  delay(1000);
  digitalWrite(redLED, LOW);

  return false;  
}

void readCardSequence()
{
  if (!readFirstCard())
    return;

  // first card OK  

  if (!readSecondCard())
    return;  

  // second card OK
  
  // done
  
  Serial.println(" Done");
  Serial.println();
  digitalWrite(greenLED, HIGH);
  delay(3000);
  digitalWrite(greenLED, LOW);  
}

void loop()
{
  readCardSequence();
}