rfid compare tag code

String functions are not appropriate, as you are working with chinks of binary data, not strings. Specifically, C strings are null terminated arrays, which means a byte containgin 0x00 will occur after the contents of the string. In the example you are playing with, there is a null in the first array element, which means that is a zero length string as far as strcmp() and friends are concerned. memcmp may be better, but I haven't checked the docs on that one myself.

Your look function needs to look something like this:

#define TAG_LEN 8
char target_tag[] = {0x00, 0x1b, 0x4e, 0xc1, 0xd0, 0x14, 0xe0, 0xd5, 0x7b }; 
void loop()
{
    byte bytes_read=0;
    char tag_read[TAG_LEN];
   // code to request tag data goes here

  // loop here until we get the required number of bytes back from the reader
  // this code will fail unpredicably in the event of communication errors
   while (bytes_read < TAG_LEN)
      while (Serial.available() > 0)
          tag_read[bytes_read++] = Serial.read();

   // compare the tag we read to see if it matches
   if (memcmp(tag_read, target_tag, TAG_LEN))
       do_something();
}

This is off the cuff, so there may be errors, especially at the boundary conditions...

-j