Hello mister_e,
I magnify code it works very well but I have not been able to configure my keyboard correctly. Can help me?.
For the access I should oppress 1,2,3, A,6 and they don't correspond this way the keys.
I include the files in proteus.
Thank you
[QUOTE=mister_e;32450]tons of different way to do it. You could even set your secret code in an array, read the keypad x times, compare the result with the array.
i'll try something.. maybe this will put some lights...
Code:
'
' Hardware assignment
' ====================
'
' System LCD
' -----------
DEFINE LCD_DREG PORTD ' LCD data port
DEFINE LCD_DBIT 4 ' LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTD ' LCD register select port
DEFINE LCD_RSBIT 2 ' LCD register select bit
DEFINE LCD_EREG PORTD ' LCD enable port
DEFINE LCD_EBIT 3 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD bus size 4 or 8
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us
'
' 4X4 matrix Keypad
' -----------------
include "c:\PBP_PROG\Include_Routines\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 ' 4 COL keypad
DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0
DEFINE KEYPAD_DEBOUNCEMS 100 ' debounce delay = 100 mSec
'
' Variables definition
' ===================
SecretCode var byte[5]
CounterA var byte
Match var byte
'
' Software/Hardware initialisation
' ================================
secretcode[0]=1
secretcode[1]=2
secretcode[2]=3
secretcode[3]=4
secretcode[4]=5
'
' Program start
' =============
Start:
match=0
lcdout $FE,1,"Enter the code"
for countera = 0 to 4
@ READKEYPAD _Key
if Key=secretcode[countera] then Match=Match+1
lcdout $FE,($C0+COUNTERA),"*"
next
if match=5 then
lcdout $FE,1,"Access Granted!"
else
lcdout $FE,1,"Access denied..."
endif
PAUSE 2000
goto start
Bookmarks