Code:
'* Author : LEONARDO BILALIS *
'* Notice : Copyright (c) 2017 [LEONARDOS BILALIS] *
'* : All Rights Reserved *
'* Date : 19/3/2017 *
'* Version : 1.3 *
'* Notes : This is an RFID ACCESS control with ulcd *
'* : and an interrupt LED on portb.3 *
'****************************************************************
@ ERRORLEVEL -306 ; this command prevents the compiler to give you a notice of
; crossing page boundary - make sure bits are set
Include "MODEDEFS.BAS"
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
DEFINE OSC 8
OSCCON=%01111000 '8 Mhz
CMCON = 7 'turn comparators off
ANSEL = 0 'All digital
;wsave VAR BYTE $20 SYSTEM ' location for W if in bank0
wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' if using $70, comment wsave1-3
' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
;-----------------------------------------------------------------
LED VAR PORTb.3 ; this is the operation led
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
;-----------------------------------------------------------------
' -----[ Variables ]-------------------------------------------------------
buf VAR byte [10]' RFID bytes buffer
tagNum VAR Byte ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table
x var byte
Symbol PWRLED = PORTB.1 ; this shows that the initialization is finished and is ready for the RFID tag
symbol LCD = PORTB.5 ; to LCD operation
Symbol rfidin = PORTB.2 ; from RFID
Symbol GROAN = PORTB.7 ; goes to groan when the rfid is denied
Symbol TXRXIN = PORTB.0 ; this is the RX input signal from the other circuit
pause 2000
serout2 LCD,32,[$55] ' uOLED Initialize
pause 2000
serout2 lcd,32,[$56,$01]
pause 1000
serout2 lcd,32,[$45]
pause 500
serout2 lcd,32,[$55]
pause 500
serout2 lcd,32,[$45]
pause 500
serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Leonardo Bilalis",$00]
pause 200
serout2 lcd,32,[$73,$02,$06,$10,$ff," Copyright 2017",$00]
pause 3000
serout2 lcd,32,[$45]
pause 1000
high pwrled 'Software controlled Power LED (if this LED is not on at load check your code)
' -----[ EEPROM Data ]-----------------------------------------------------
Tag1 DATA "xxxxxxxxxx"
Tag2 DATA "xxxxxxxxxx"
Tag3 data "xxxxxxxxxx"
Tag4 data "xxxxxxxxxx"
Tag5 data "xxxxxxxxxx"
Tag6 Data "xxxxxxxxxx"
Tag7 data "xxxxxxxxxx"
Tag8 data "xxxxxxxxxx"
Tag9 data "xxxxxxxxxx"
Tag10 data "xxxxxxxxxx"
' -----[ Initialization ]--------------------------------------------------
LOW portb.4 ' lock the door!
'----- [ LOGO ] ---------------------------------------------------------------
logo:
serout2 LCD,32,[$55] ' uOLED Initialize
pause 500
gosub Logo_png
' -----[ Program Code ]----------------------------------------------------
Main:
serin2 portb.2,84,[WAIT($02),str BUF\10]
pause 500
Check_List:
FOR tagNum = 1 to 10 ' 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 (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
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $C0]
pause 500
FREQOUT groan, 1000 */ $100, 115 */ $100 ' groan
pause 500
serout2 lcd,32,[$45]
pause 500
serout2 lcd,32,[$59,$03,$00]
pause 200
goto main
Tag_Found:
IF tagNum = 1 then Leonardo
IF tagNum = 2 then ELENI
if tagnum = 3 then MAMAANNA
if tagnum = 4 then THEIAMARIA
if tagnum = 5 then MARIA
if tagnum = 6 then displayName6
if tagnum = 7 then displayName7
if tagnum = 8 then displayName8
if tagnum = 9 then displayname9
if tagnum = 10 then displayname10
GOTO main
Leonardo:
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $40]
pause 500 'Pause ,5 sec then clear display
goto open_door
ELENI:
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $00]
pause 500 'Pause ,5 sec then clear display
goto open_door
MAMAANNA:
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you ANNA",$00]
pause 200
serout2 lcd,32,[$73,$02,$06,$10,$ff," Please enter code",$00]
pause 500
goto open_door
THEIAMARIA:
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you MARIA",$00]
pause 200
serout2 lcd,32,[$73,$02,$06,$10,$ff," Please enter code",$00]
pause 500
goto open_door
MARIA:
serout2 lcd,32,[$59,$03,$01]
pause 1000
serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Thank you MARIA",$00]
pause 200
serout2 lcd,32,[$73,$02,$06,$10,$ff," Please enter code",$00]
pause 500
goto open_door
displayName6:
displayName7:
displayName8:
displayName9:
displayName10:
'----------------------OPEN THE DOOR------------------------------
open_door:
HIGH portb.4 ' remove latch
pause 5000
if TXRXIN = 1 then
pause 8000
endif
LOW portb.4 ' restore latch
serout2 lcd,32,[$45]
pause 500
serout2 lcd,32,[$59,$03,$00]
goto main
;DOOR:
; serout2 lcd,32,[$45]
; serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff,"DOOR is OPENED",$00]
; return
'----------------- [ LOGO Routine ] ------------------------------
Logo_png:
serout2 lcd,32,[$40, $49, $00, $00, $80, $80, $10, $00, $00, $00]
pause 3000
serout2 lcd,32,[$59,$03,$00]
pause 200
return
'-------------------- [ CLEAR ] ----------------------------------
Clearlcd:
serout2 lcd,32,[$45]
pause 500
goto logo
'---[TMR1 - interrupt handler]--------------------------------------------------
ToggleLED1:
TOGGLE led
@ INT_RETURN
and the code for the PIC16F84A
Bookmarks