rfid compare tag code

The tag code "001B4EC1D014E0D57B" is the code that I have copied from serial monitor after reading a tag.

This is probably the hex representation of a binary number, not really a string. try initializing your target array like this:

char target[] = {0x00, 0x1b, 0x4e, 0xc1, 0xd0, 0x14, 0xe0, 0xd5, 0x7b };

Also, I just glanced at it but your loop function doesn't look right. You are asking for a new tag every time you run loop and apparently assuming that the data will be returned immediately. This is not necessarily the case. You are also assuming that the data is made available in a single uninterupted stream, and this is almost certainly wrong. Look at the part of the code where you are reading the data; that section probably needs a re-write.

I would like to put 50+ tags in the memory that trigger a certain action.

Hmm, the ATmega8 only has 1k of RAM, and your target strings are about 10 bytes long, so that's half the available memory just to store the strings you are matching against. It'll probably work, as long as the rest of your code isn't too memory intensive, but you should be aware you are approching the limits of the device and method you're using.

Of course, the 168 has twice the RAM and there are methods for storing data in program space (flash), but they're not as straightforward as the methods you use now.

-j