N and V column

Column #120: You Can’t Touch That: Non-contact Access Control
Page 68 The Nuts and Volts of BASIC Stamps (Volume 6)
Note that the SERIN line is really long, but needs to be on one line to make sure that all 11
bytes (header plus 10) received are in fact received properly. For publication, I've split the
line, but you'll find it all together in the downloadable version of the code.
With the tag ID stored in the BS1's RAM, we can compare it to our table entries to determine
whether the tag presented is a match or not. Admittedly, this looks a little hairy, but it's really
not that bad. To keep things concise, I'm only showing the first and last bytes, but the same
code is required for all ten elements of the RFID tag string.
Check_List:
FOR tagNum = 0 TO LastTag
pntr = tagNum * 10 + 0
READ pntr, char
IF char <> tag0 THEN Bad_Char
' removed for clarity
pntr = tagNum * 10 + 9
READ pntr, char
IF char <> tag9 THEN Bad_Char
GOTO Tag_Found
Bad_Char:
NEXT
As you can see, comparing each byte of the RFID string against a table entry requires three
steps that are placed in a loop: 1) We create a pointer to the corresponding position of the
table entry, 2) We read the character from the table, and then 3) We compare the two bytes. If
they don't match the program jumps to the label called Bad_Char and we'll either move to the
next table entry, or if at the end of the table we'll fall through the loop.
Let's say we do have a match. When that occurs we will jump to the label called Tag_Found
and execute the door-opening code:
Tag_Found:
DEBUG "Entry: ", #tagNum, CR
HIGH Latch
SOUND Spkr, (114, 165)
LOW Latch
GOTO Main