RFID Reader documentation v2.1
Copyright © Parallax Inc. RFID Card Reader Serial & USB (#28140 / 28340) v2.1 8/28/2008 Page 10 of 11
LastTag CON 3
#DEFINE __No_SPRAM = ($STAMP < BS2P) ' does module have SPRAM?
' -----[ Variables ]-------------------------------------------------------
#IF __No_SPRAM #THEN
buf VAR Byte(10) ' RFID bytes buffer
#ELSE
chkChar VAR Byte ' character to test
#ENDIF
tagNum VAR Nib ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table
' -----[ EEPROM Data ]-----------------------------------------------------
Tag1 DATA "0F0184F20B" ' valid tags
Tag2 DATA "0F01D9D263"
Tag3 DATA "04129C1B43"
Name0 DATA "Unauthorized", CR, 0
Name1 DATA "George Johnston", CR, 0
Name2 DATA "Dick Miller", CR, 0
Name3 DATA "Mary Evans", CR, 0
' -----[ Initialization ]--------------------------------------------------
Reset:
HIGH Enable ' turn of RFID reader
LOW Latch ' lock the door!
' -----[ Program Code ]----------------------------------------------------
Main:
LOW Enable ' activate the reader
#IF __No_SPRAM #THEN
SERIN RX, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID
#ELSE
SERIN RX, T2400, [WAIT($0A), SPSTR 10]
#ENDIF
HIGH Enable ' deactivate reader
Check_List:
FOR tagNum = 1 TO LastTag ' scan through known tags
FOR idx = 0 TO 9 ' scan bytes in tag
READ (tagNum - 1 * 10 + idx), char ' get tag data from table
#IF __No_SPRAM #THEN
IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table
#ELSE
GET idx, chkChar ' read char from SPRAM
IF (char <> chkChar) THEN Bad_Char ' compare to table
#ENDIF
NEXT
GOTO Tag_Found ' all bytes match!