How can I program Arduino to detect when a RFID tag is removed?

Hello forum.
I’m working on a project at school, and it’s basically a media player. Different tags trigger different songs.
and I got that part covered.
But I want the songs to stop playing when the tag is removed. Like a momentary switch for the music

I’m having trouble finding out how I’m supposed to write the code. Spent the last two days with it, but without success

The reader is a RC522
with this library:

There are two handy functions:
Makes the arduino read a card only once (In other words, keep it from flooding the serial monitor with data)

Returns true if a new card is present.
But this function ignores card put in halt mode!

I’d be very happy if someone could shed some light on this.
Is it a hardware problem?
I have a couple of PN532-readers as well. I’ve noticed that they can read some tags that the RC522 can’t

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

byte startStopTag [4]= {0x9D,0x2D,0xD6,0x2C};
int state = 0;

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

void setup() {
    Serial.begin(115200); // Initialize serial communications with the PC
    SPI.begin();            // Init SPI bus
    mfrc522.PCD_Init(); // Init MFRC522 card



  void loop () {


    if ( ! mfrc522.PICC_IsNewCardPresent() && state==0) {
    if ( ! mfrc522.PICC_ReadCardSerial()) {

   boolean toggleStartStop = true;
if (state==1)
  for (byte i = 0; i < mfrc522.uid.size; i++) {
  Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  Serial.print(mfrc522.uid.uidByte[i], HEX);
    if (mfrc522.uid.uidByte[i] != startStopTag[i]) toggleStartStop = false;

 if (toggleStartStop )    //&& state==1



I've also noticed that the readers have an IRQ pin. Anyone with experience on that?


Well I looked at the data sheet a few days back and coudn’t see any way you could do it. Most RFID readers only give the token on code. Occasionally you have a token present signal but I can’t see on in the data sheet of your device.

Ok thanks mike. Where in the datasheets can I see this? Want to find out if my other readers can do this

Have one of these:

and one of these:

and one of those ID-12 from sparkfun

Where in the datasheets can I see this?

Well as it doesn't mention it then you can't see it. If it were there then it would be in the commands you send it or as a pin on the chip, but like I say I couldn't find anything.

I have worked on RFID readers for a living and normally repeat reads are suppressed. Although there was a call for this not to be true on some 135 MHz readers. These kept repeatedly sending the code until the token was removed. Then it was up to the receiving software to sort out when a new token code was produced.

You can make a simple RFID sniffer for 135MHz tokens that just tell you if there is a token in the field and do not read anything from them, one such is here:- This would work with the tokens you read on the Sparkfun reader but you could not have it on at the same time you are reading the token.