In my project I read the unique ID from an RFID tag, the result is in the form uint8_t TagRead[4]
.
The result is compared with a number of predefined tag ID values to establish which tag has been read.
For example:
uint8_t RED1[4] = { 0x73, 0xD5, 0xB7, 0xAC };
uint8_t RED2[4] = { 0x7E, 0x27, 0x49, 0x4E };
uint8_t RED3[4] = { 0x02, 0xFD, 0x06, 0x40 };
uint8_t GREEN1[4] = { 0xAB, 0xEC, 0x68, 0x80 };
uint8_t GREEN2[4] = { 0xEE, 0x20, 0x50, 0x4E };
uint8_t GREEN3[4] = { 0x27, 0x06, 0x40, 0x73 };
if (*((uint32_t *)TagRead) == *((uint32_t *)RED2)) {
// RED2 tag has been read
}
else if (*((uint32_t *)TagRead) == *((uint32_t *)GREEN3)) {
// GREEN3 tag has been read
}
My question relates to being able to assign a type/category to a group of tags so that an action can be performed based on the colour of the tag that has been scanned.
It may be that when a RED tag is scanned we switch on a red LED and when a GREEN tag is scanned we switch on a blue LED.
Because there are approximately 50 tags of each colour, I don't want to to have to list all the tag names in the If statement. Instead, is it possible to assign the colour to the tag?
It would then be possible to do:
If scanned tag is of type RED, do red action. If scanned tag is of type GREEN do green action.
Thanks for your help.