When the RFID card is removed the card number should be printed

Hello, When the RFID card is tapped to the RFID Reader the Serial Plotter Displays code of the RFID, I want to make some changes in the code as when the card is removed the same tag number should be printed on the serial moniter.

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

#define SS_1_PIN 10

#define RST_PIN 9

MFRC522 rfid(SS_1_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;
// Init array that will store new NUID
byte nuidPICC[4];
void setup() {
Serial.begin(115200);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
rfid1.PCD_Init(); // Init MFRC522

}

void loop() {
RFID();
}

//===========================================

void RFID()
{
//Serial.println(“pirmais”);

for (byte i = 0; i < 6; i++) {
key.keyByte = 0xFF;

  • }*
  • // Look for new 1 cards*
  • if ( ! rfid.PICC_IsNewCardPresent())*
  • return;*
  • // Verify if the NUID has been readed*
  • if ( !rfid.PICC_ReadCardSerial())*
  • return;*
  • // Store NUID into nuidPICC array*
  • for (byte i = 0; i < 4; i++) {*
    nuidPICC = rfid.uid.uidByte*;*
    * }*

* Serial.print(F("In dec: "));*
* printDec(rfid.uid.uidByte, rfid.uid.size);*
* Serial.println();*
* // Halt PICC*
* rfid.PICC_HaltA();
_ // Stop encryption on PCD*
* rfid.PCD_StopCrypto1();*
}
//=============================================
/**
* Helper routine to dump a byte array as dec values to Serial.
/
void printDec(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer < 0x10 ? " 0" : " ");
Serial.print(buffer, DEC);
}
}*_

Welcome to the Arduino forum. Did you actually wright the code? Is there something that can tell your code when the card is removed? What have you tried?

Paul