hi all,
this is my code for your reference....there is somewhere a mistake that cannot find.
Code:@ DEVICE PIC16F628A INCLUDE "modedefs.bas" CMCON = 7 DEFINE OSC 4 'Set oscillator in MHz DEFINE LCD_DREG PORTB 'define port to LCD DEFINE LCD_DBIT 4 'RB4 RB5 RB6 RB7 to D4 D5 D6 D7 display DEFINE LCD_RSREG PORTA 'RS on porta DEFINE LCD_RSBIT 0 'RS on porta.0 DEFINE LCD_EREG PORTA 'Enable on porta DEFINE LCD_EBIT 1 'Numero Enable porta.1 DEFINE LCD_BITS 4 ' DEFINE LCD_LINES 2 'lines 2 PAUSE 200 ' Stop 200ms LCDOUT $FE,1 ' power lcd Lcdout $FE,1,4 lcdout $FE, 1," Copyright 2011" lcdout $FE, $C0,"***********" pause 2000 lcdout $FE,1 ' -----[ Variables ]------------------------------------------------------- buf VAR byte [12]' RFID bytes buffer tagNum VAR Byte ' from EEPROM table idx VAR Byte ' tag byte index char VAR Byte ' character from table ' -----[ EEPROM Data ]----------------------------------------------------- Tag1 DATA "450052B6BC1D" Tag2 DATA "450052F2EB0E" ' -----[ Initialization ]-------------------------------------------------- high portb.1 ' turn off RFID reader portb.1 is the reciever port LOW portb.2 ' lock the door! Low portb.3 ' Turn off LED ' -----[ Program Code ]---------------------------------------------------- Main: lcdout $FE,1," Please use your" lcdout $FE, $C0," TAG" pause 500 high portb.3 low portb.1 ' activate the reader pause 500 SERIN2 portb.1, 84, [WAIT($34),STR buf\12] pause 500 high portb.1 ' deactivate reader Check_List: FOR tagNum = 1 to 2 ' scan through known tags FOR idx = 0 TO 11 ' scan bytes in tag READ (((tagNum-1)*12 ) + idx), char ' get tag data from table IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table NEXT GOTO Tag_Found ' all bytes match! Bad_Char: ' try next tag NEXT Bad_Tag: tagNum = 0 FREQOUT porta.3, 1000 */ $100, 115 */ $100 ' groan lcdout $FE, 1," invalid TAG" lcdout $FE, $C0," try again" pause 1000 lcdout $FE,1 GOTO Main Tag_Found: IF tagNum = 1 then displayName1 IF tagNum = 2 then displayName2 GOTO Main displayName1: lcdout $FE, 1," name_1" lcdout $FE, $C0, "ACCESS GRANDED" pause 1000 'Pause ,5 sec then clear display goto open_door displayName2: lcdout $FE, 1," name_2" LCDout $FE, $C0," ACCESS GRANDED" pause 1000 'Pause ,5 sec then clear display goto open_door open_door: HIGH portb.2 ' remove latch pause 500 LOW portb.2 ' restore latch Low portb.3 ' LED OFF GOTO Main




Bookmarks