rfid NFC

Tengo un lio tremendo con las tarjetas NFC, he intentado descriminar alguna tarjeta para el control de acceso pero no lo consigo, incluso llegue a escribir datos en algunos bloques estoy echo un lio con las tarjetas,
¿¿¿Solo bastaria con obtener el UID de la tarjeta ??? si es asi tengo mucho codigo inservible.

A ver si me podeis ayudar.

/*
 *  This sketch authenticates and reads a block in a RFID tag
 */

uint8_t dataRX[35];//Receive buffer.
uint8_t dataTX[35];//Transmit buffer.
uint8_t _UID[4];// stores the UID (unique identifier) of a card.
uint8_t keyAccess[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } ;// stores the key or password.
uint8_t address = 0x04;//Address to read.
uint8_t ATQ[2];//Answer to request
uint8_t state;//state of the process
uint8_t aux[16];//Auxiliar buffer. 

void setup()
{
  //Start serial port 115200 bps:
  Serial.begin(115200);
  delay(100);
  Serial.print("RFID/NFC @ 13.56 MHz module started");
  delay(1000);
  //!It is needed to launch a simple command to sycnchronize
  //getFirmware();
  configureSAM();
}

void loop()
{
  Serial.print("\n");
  Serial.println("Ready to read...");
  /////////////////////////////////////////////////////////////
  //Get the UID Identifier
  init(_UID, ATQ);
  Serial.print("\n");
  Serial.print( "The UID : ");
  print(_UID , 4);
  /////////////////////////////////////////////////////////////
  //Auntenticate a block with his keyAccess
  state = authenticate(_UID, address, keyAccess);
  Serial.print("\n");

  if ( state == 0) {
    Serial.println("Authentication block OK");
  } 
  else {
    Serial.println("Authentication failed");
  }
  /////////////////////////////////////////////////////////////
  //Read from address after authentication
  state = readData(address, aux);
  Serial.print("\n");

  if (state == 0) {
    Serial.println("Read block OK");
  } 
  else {
    Serial.println("Read failed");
  }

  Serial.print("\n");
  Serial.print("Data readed : ");
  print(aux , 16);
  Serial.print("\n");
  delay(2000);
}
//**********************************************************************
//!The goal of this command is to detect as many targets (maximum MaxTg)
// as possible in passive mode.
uint8_t init(uint8_t *UID , uint8_t *ATQ)   //! Request InListPassive
{
  Serial.flush();

  dataTX[0] = 0x04; // Length
  lengthCheckSum(dataTX); // Length Checksum
  dataTX[2] = 0xD4;
  dataTX[3] = 0x4A; // Code
  dataTX[4] = 0x01; //MaxTarget
  dataTX[5] = 0x00; //BaudRate = 106Kbps
  dataTX[6] = 0x00; // Clear checkSum position
  checkSum(dataTX); 

  sendTX(dataTX , 7 ,23);

  for (int i = 17; i < (21) ; i++){
    _UID[i-17] = dataRX[i];
    UID[i-17] = _UID[i-17];
  }

  ATQ[0] = dataRX[13];
  ATQ[1] = dataRX[14];

  if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
    return 0;
  } 
  else {
    return 1;
  }
}
//**********************************************************************
//!A block must be authenticated before read and write operations
uint8_t authenticate(uint8_t *UID, uint8_t blockAddress, uint8_t *keyAccess)
{
  dataTX[0] = 0x0F;
  lengthCheckSum(dataTX);
  dataTX[2] = 0xD4;
  dataTX[3] = 0x40; // inDataEchange
  dataTX[4] = 0x01; //Number of targets
  dataTX[5] = 0x60; // Authentication code
  dataTX[6] = blockAddress;
  for (int i = 0; i < 6 ; i++) {
    dataTX[i + 7] = keyAccess[i];
  }
  dataTX[13] = UID[0];  
  dataTX[14] = UID[1];
  dataTX[15] = UID[2];  
  dataTX[16] = UID[3];
  dataTX[17] = 0x00;
  checkSum(dataTX);
  sendTX(dataTX , 18 ,14);

  if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    return 0;
  } 
  else {
    return 1;
  }
}
//**********************************************************************
//!Print data stored in vectors .
void print(uint8_t * _data, uint8_t length)
{
  for (int i = 0; i < length ; i++){
    Serial.print(_data[i], HEX);
    Serial.print(" ");
  }
  Serial.print("\n");
}
//**********************************************************************
//!This command is used to set internal parameters of the PN532,
bool configureSAM(void)//! Configure the SAM
{
  Serial.print("                ");

  dataTX[0] = 0x05; //Length
  lengthCheckSum(dataTX); // Length Checksum
  dataTX[2] = 0xD4;
  dataTX[3] = 0x14;
  dataTX[4] = 0x01; // Normal mode
  dataTX[5] = 0x14; // TimeOUT
  dataTX[6] = 0x00; // IRQ
  dataTX[7] = 0x00; // Clean checkSum position
  checkSum(dataTX);

  sendTX(dataTX , 8, 13);
}
//**********************************************************************
//!Send data stored in dataTX
void sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength)
{

  Serial.write((uint8_t)0x00);
  Serial.write((uint8_t)0x00);
  Serial.write((uint8_t)0xFF); 

  for (int i = 0; i < length; i++) {
    Serial.write((uint8_t)dataTX[i]);
  }
  Serial.write((uint8_t)0x00);

  delay(5);
  waitResponse();
  for (int i = 0; i < 5 ; i++) {
    dataRX[i] = Serial.read();
  }
 
  int val = 0xFF;
  int cont = 0x00;
  while(val != 0x00) { //Wait for 0x00 response
    val = Serial.read();
    delay(5);
    cont ++;
  }
  
  for (int i=5; i < outLength; i++) {
    dataRX[i] = Serial.read();//read data from the module.
  }

}
//**********************************************************************
//!Calculates the checksum and stores it in dataTX buffer
void checkSum(uint8_t *dataTX)
{
  for (int i = 0; i < dataTX[0] ; i++) {
    dataTX[dataTX[0] + 2] += dataTX[i + 2];
  }
  byte(dataTX[dataTX[0] + 2]= - dataTX[dataTX[0] + 2]);
}
//**********************************************************************
//!Calculates the length checksum and sotres it in the buffer.
uint8_t lengthCheckSum(uint8_t *dataTX)
{
  dataTX[1] = byte(0x100 - dataTX[0]);
}
//**********************************************************************
//!Read 16 bytes from  address .
uint8_t readData(uint8_t address, uint8_t *readData) //!Reading
{
  Serial.print("                ");

  dataTX[0] = 0x05;
  lengthCheckSum(dataTX); // Length Checksum
  dataTX[2] = 0xD4; // Code
  dataTX[3] = 0x40; // Code
  dataTX[4] = 0x01; // Number of targets
  dataTX[5] = 0x30; //ReadCode
  dataTX[6] = address;  //Read address
  dataTX[7] = 0x00;
  checkSum(dataTX);
  sendTX(dataTX , 8, 30);
  memset(readData, 0x00, 16);  

  if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    for (int i = 12; i < 28; i++) {
      readData[i-12] = dataRX[i];
    }
    return 0;
  } 
  else {
    return 1;
  }
}