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:
mfrc522.PICC_HaltA()
Makes the arduino read a card only once (In other words, keep it from flooding the serial monitor with data)

mfrc522.PICC_IsNewCardPresent()
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
    mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
   delay(20);


}

 
  

  void loop () {



    

    if ( ! mfrc522.PICC_IsNewCardPresent() && state==0) {
      Serial.println("STOP");  
      state=1;
    return;
    }
    
    
    if ( ! mfrc522.PICC_ReadCardSerial()) {
 
      return;
    }
        



   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;
  
 //
} 
  Serial.println();



 if (toggleStartStop )    //&& state==1
{Serial.println("toggleStartStop");
mfrc522.PICC_HaltA();
state==0;
//mfrc522.PCD_Reset();
}   

    
}




  }

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

Anyone?

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: http://www.ebay.com/itm/Mini-PN532-NFC-RFID-Reader-Writer-Module-Compatible-Arduino-Android-Phone-/400762658893?pt=LH_DefaultDomain_0&hash=item5d4f50e04d

and one of these: http://www.ebay.com/itm/New-PN532-NFC-module-Reader-Writer-3-3V-5V-Arduino-compatible-with-2-S50-card-/161292573998?pt=LH_DefaultDomain_0&hash=item258dc95d2e

and one of those ID-12 from sparkfun https://www.sparkfun.com/products/11827

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:- http://www.nearfield.org/2009/03/rfid-sniffer-workshop 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.