I have an 12LA reader hooked to my UNO. I am using code written by Barragan. The reader works great but now I need to compare the read to known tags. This is what the serial is giving me on a tag read.
6A 00 49 F6 B2 - five bytes of HEX
I want to compare this to known tag values so I can determine if it is a match.
You need to get those bytes into a single number.
Use a long long type of variable to hold both your required token and what is returned from the reader. Call it say readToken.
Put the reader's number in a byte at a time by logic ORing the number with the byte.
So shift the long long up 8 places, OR the last byte, and repeat untill all the bytes are in.
For your known token just declare the number like this
long long authorised = 0x6A0049F6B2;
then to test just use an if statement like :-
if ( authorised == readToken) { // do your thing
}
I am not sure how the string is received from serial even though the console shows HEX. I tried a memcmp() with my value, mytag,.
byte mytag[5] = {01101010, 0000, 01001001, 11110110, 10110010}; i
an array of bytes.
The console prints this array as
6A049F6B2
while the card read shows up on the console as
6A0049F6B2
if (memcmp(mybyte, mytag, 5) == 0){
Serial.print("yes");
}
No match yet
I built mybyte in the same for loop that prints each byte of the read card to the screen..
Not sure if I;m dealing with apples and oranges. The HEX number of the card would not fit into any number type. that I tries
Fixed. Thanks you for the help. I am a little new to serial like this but I have done work on displays, Never done learning. That;s why I'm here. I will clean the code up and leave it here later for another beginner. Thanks again.