Hi Everyone,
I'm using mister_e's keypad.bas etc and trying to make a combination access for a driveway gate and not getting the results I am looking for. Does anyone see any glaring errors?
Thanks
JS
Code:
@MyConfig = _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF 
@MyConfig = MyConfig & _BODEN_OFF 
@ __config  MyConfig
'@ __CONFIG _HS_OSC & _WDT_ON & _PWRTE_ON  & _LVP_OFF & _CP_OFF
Define PIC16F877A
@ errorlevel -230
CMCON  = 7  
ADCON1 = 7 
define OSC 20
TrisD = %00000000

DEFINE LCD_DREG PORTA
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTA
    DEFINE LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4

    include "keypad.bas"
    
    DEFINE KEYPAD_ROW        4        ' 4 ROW keypad       
    DEFINE KEYPAD_ROW_PORT   PORTB    ' ROW port = PORTB
    DEFINE KEYPAD_ROW_BIT    4        ' ROW0 = PORTB.4
    DEFINE KEYPAD_COL        4        ' 3 COL keypad
    DEFINE KEYPAD_COL_PORT   PORTB    ' COL port = PORTB
    DEFINE KEYPAD_COL_BIT    0        ' COL0 = PORTB.1
    DEFINE KEYPAD_DEBOUNCEMS 50       ' debounce delay = 50 mSec
    DEFINE SCAN_ONCE         1

    OPTION_REG.7=0        ' Enable internal crap pull-up :D

    PORTB = 0             '  
    TRISB = %11110000     '
      
    ByteA var byte         '
    Combo1 var byte [4]
    INTCON = %10001000    ' Enable global interrupt
                          ' Enable interrupt on PORTB change
    on interrupt goto KeypadInt
    CLEAR

Init:    
    lcdout $FE,1,"Press any Key"
Start:
    if ByteA then
    If ByteA = 4  then ByteA = "A"
    if ByteA = 5  then ByteA = 4
    if ByteA = 6  then ByteA = 5
    if ByteA = 7  then ByteA = 6
    if ByteA = 8  then ByteA = "B"
    if ByteA = 9  then ByteA = 7
    if ByteA = 10 then ByteA = 8
    if ByteA = 11 then ByteA = 9
    if ByteA = 12 then ByteA = "C"
    if ByteA = 13 then ByteA = "*"
    if ByteA = 14 then ByteA = 0
    if ByteA = 15 then ByteA = "#"
    if ByteA = 16 then ByteA = "D"
        LCDOUT $FE,1,"Key=",dec bytea
        ByteA = 0
        pause 1000
        goto init
        'else
           if ByteA != 0 then  gosub combo
else   
endif
goto start

         
disable
KeypadINT:    
    @ READKEYPAD _ByteA
    TRISB=%11110000
    PORTB=0
    INTCON.0=0
    resume
enable
combo: 
       if ByteA = 7 then
       combo1[0] = 7
       gosub digit2
       else
       endif
        return

digit2: if (ByteA = 8) and (combo1[0] = 7)  then
        combo1[1] = 8
        gosub Digit3 
        else
       endif
       return
Digit3:       if (ByteA = 65) and (combo1[1]=8 ) then
              combo1[2] = 65
              gosub Digit4
              else
       endif
       return
Digit4:       if (ByteA = 5) and (combo1[2] = 65) then
        combo1[3] = 5
       gosub Digit5
       else
       endif
       return
Digit5:       if (ByteA =68) and (combo1[3] = 5) then
        combo1[4] = 68
        goto Digit6
        else
       endif
       return
Digit6: if combo1[4] = 68 then
        lcdout "Gate Opening"
        PortD.2 = 1
        pause 30000
        lcdout "Gate Closing"
        pause 30000
       ByteA = 0
       Combo1 = 0
        endif
       goto start   ' Combination 78A5D
       
       
       
       
       
       end