ALLRIGHTY THEN,
Hi Steve, Darrel and all,
For starters . . . Lookup table listed will do the kepad remapping of my long and convouluted code? Cool, I must learn more about this, also how to set up eprom, as I have never figured that out.
Darrel, you said my code never went to gosub, . . . the if bytea != 0 then gosub combo, will not do it?
before you and Steve posted, but after skimask did I wrote the following
and it opened the gate with the push of any button, well almost, really it lied and said the gate was opening, and I have not had time to redress this issue.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" pause 1000 lcdout 254,1 lcdout 254,128,"PIC Self Test" pause 1000 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 ' Flags = 0 ByteA var byte ' Combocount var byte INTCON = %10001000 ' Enable global interrupt ' Enable interrupt on PORTB change on interrupt goto KeypadInt CLEAR lcdout 254,128," Initializing" LCDOUT 254,192,"System" pause 1000 Portd.2 = 0 combocount = 0 Init: lcdout $FE,1 LCDOUT 254,128,"AUTHORIZATION" LCDOUT 254,192,"REQUIRED TO OPEN" LCDOUT 254,153,"THIS GATE" LCDOUT 254,212,"KEY ENTRY CODE" disable KeypadINT: @ READKEYPAD _ByteA TRISB=%11110000 PORTB=0 INTCON.0=0 resume enable 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" if ByteA != 0 then gosub combo ByteA = 0 pause 1000 goto init 'else else endif goto start combo: LCDOUT $FE,1,"Key=",dec ByteA if ((ByteA = 7) and (combocount = 0)) then combocount = %00000001 pause 1000 else combocount = 0 endif if ((ByteA = 8) and (combocount = %00000001)) then combocount = %00000011 pause 1000 else combocount = 0 endif if ((ByteA = 65) and (combocount = %00000011)) then combocount = %00000111 pause 1000 else combocount = 0 endif if ((ByteA = 5) and (combocount = %00000111)) then combocount = %000011111 pause 1000 else combocount = 0 endif if ((ByteA =68) and (combocount = %00001111)) then combocount = %00011111 pause 1000 else combocount = 0 endif if combocount = %00011111 then PortD.2 = 1 lcdout 254,1 pause 10 lcdout 254,128,"Gate Opening" : pause 30000 lcdout 254,1 pause 10 lcdout 254,192,"Gate Closing" : pause 30000 : ByteA = 0 : combocount = 0 lcdout 254,1 PortD.2 = 0 'endif goto init ' Combination 78A5D end
I even played with another asm. code file emailed to me, that was fun learning how to use mpasm in windows, and editing the asm file without actual Knowledge of assembly, but I got it to compile and, you guessed it, it didn't work as expected either, just outputted a few strings all over the lcd. So here i am looking at the examples you and Steve have provided, thinking I will figure this out, likely not today
JS
edit1:Well I haven't learned all the lessons here, but the code works really well, Thanks!
edit2:Wow now I see how eprom works! Thanks again Darrel!
edit3: Thanks Steve for lookup table, now that makes sense too!
Just modified code to work as alarm console too, cool!







Bookmarks