N and V column
Column #120: You Can’t Touch That: Non-contact Access Control
The Nuts and Volts of BASIC Stamps (Volume 6) • Page 71
Check_List:
FOR tagNum = 1 TO LastTag
FOR idx = 0 TO 9
READ (tagNum - 1 * 10 + idx), char
#IF __No_SPRAM #THEN
IF (char <> buf(idx)) THEN Bad_Char
#ELSE
GET idx, chkChar
IF (char <> chkChar) THEN Bad_Char
#ENDIF
NEXT
GOTO Tag_Found
Bad_Char:
NEXT
As with the BS1, a loop is used to work through the known tag strings. What we're able to do
here, however, is use a second loop to test each byte of the received string. The inner loop
reads the appropriate byte from the current tag data and compares it against the corresponding
tag byte from the reader. Our conditional symbol sets up the code to make the comparison
against a byte in the variable array or against a byte from the Scratchpad. Note that the
Scratchpad cannot be treated like an array so we are forced to use GET to access the
appropriate byte.
Okay, moving on to a good tag we will do the same as before: sound the beeper (with
FREQOUT) and disable the security lock. Remember that FREQOUT is one of those
instructions that differs from one BASIC Stamp model to another, so conditional compilation
constants are used to keep the timing (two seconds) and tone (880 Hz) the same, no matter
which module we use.
Tag_Found:
GOSUB Show_Name
HIGH Latch
FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj
LOW Latch
GOTO Main
We've also added the ability to display the name of the person who is assigned to the valid
tag. A simple loop will send the characters in the name to a display – we'll keep it easy and
use the Debug Terminal.