FDX-B 134.2 kHz RFID reader

Hi!

@red_car , can you help with my coding?
I copied your code and hooked up my arduino and rfid reader and reads small chips and both of my cats. Now i want a action/ command to happen when a certain "chip/ cat" activates the rfid.

Here's the code

<
#include <SoftwareSerial.h>

SoftwareSerial RFID(7, 8);

byte b;
byte buffer[30];

uint8_t idx;
boolean started = false;

byte XOR;
byte inverted;

uint32_t value;

void setup()
{
Serial.begin (9600);
RFID.begin (9600);
}

void loop()
{

String content = "";
while (RFID.available())
{
b = RFID.read();

if (b == 0x02) // Start byte
{
  idx = 0;
  started = true;
}



if (started) // Ignore anything received until we get a start byte.
{
  buffer[idx++] = b;

  if (b == 0x03) // End byte
  {
    started = false;
  
    
    
    // Display the received data.
    Serial.print("Received data: ");
    for (int x = 0; x < idx; x++)
    {
      if (buffer[x] < 0x10)
      {
        Serial.print("0"); // Pad with leading 0
      }
      Serial.print (buffer[x], HEX);
      Serial.print (" ");
    }
    Serial.println("");


    // Check we received the message ok.  XOR checksum on bytes 01-26 should match byte 27.
    XOR = buffer[1];
    for (int x = 2; x <= 26; x++)
    {
      XOR ^= buffer[x];  
    }
    Serial.print("Calculated checksum: ");
    Serial.print(XOR, HEX);

    if (XOR == buffer[27])
      Serial.println(" (Correct)");
    else
      Serial.println(" (Error)");


    // Check the inverted XOR checksum
    inverted = ~XOR;
    Serial.print("Inverted checksum: ");
    Serial.print(inverted, HEX);
    if (inverted == buffer[28])
      Serial.println(" (Correct)");
    else
      Serial.println(" (Error)");

    
    // Extract the card number from bytes 01 (LSB) - 10 (MSB).
    value = 0;
    for (int x = 10; x >= 1; x--)
    {
      if(buffer[x] <= '9')
        value = (value<<4) + buffer[x] - '0';  
        
      else
        value = (value<<4) + buffer[x] - '7';  
    
    }
    Serial.print("Card number: ");
    Serial.println(value);

    

    // Extract the country number from bytes 11 (LSB) - 14 (MSB).
    value = 0;
    for (int x = 14; x >= 11; x--)
    {
      if(buffer[x] <= '9')
        value = (value<<4) + buffer[x] - '0';
      else
        value = (value<<4) + buffer[x] - '7';  
    }
    Serial.print("Country number: ");
    Serial.println(value);


    // Extract the Data Block from byte 15.
    Serial.print("Data block: ");
    Serial.println(buffer[15] - '0');

    
    // Extract the Animal Flag from byte 16.
    Serial.print("Animal flag: ");
    Serial.println(buffer[16] - '0');


    Serial.println("\r");
  }
}

}
}

This is what i get :

Received data: 02 37 30 36 36 35 34 46 30 32 33 34 38 33 30 30 31 30 30 30 30 30 30 30 30 30 30 7F 80 03
Calculated checksum: 7F (Correct)
Inverted checksum: 80 (Correct)
Card number: 256206343
Country number: 900
Data block: 0
Animal flag: 1

How can i code it so just my cat can activate it?

Thanks!