PDA

View Full Version : set the password using keypad 3x4



elyasfy
10-23-2010, 12:57 PM
im using for my graduation project a keypad with 3 colum and 4 row

i already do the configration but i dont know how to set the pasword

for example when im using if statment

it accept password "12" and "21" and its not taking it digit by digit

this is my code
please help

keypad:
DO

HIGH 2
LOW 4
LOW 6
LOW 7


IF (IN3=1) THEN 'for row 1
a=1

DEBUG "1"
PAUSE 100

ELSEIF (IN1=1) THEN
a=2

DEBUG "2"
ELSEIF (IN5=1) THEN
a=3
DEBUG "3"

ENDIF
PAUSE 100


Raw2:

HIGH 7 ' for row 2
LOW 2
LOW 4
LOW 6

IF (IN3=1) THEN
a=4
DEBUG "4"

ELSEIF(IN1=1) THEN
a=5
DEBUG "5"
ELSEIF(IN5=1) THEN
a=6
DEBUG "6"

ENDIF
PAUSE 100


Raw3:

HIGH 6 'for row 3
LOW 4
LOW 7
LOW 4

IF (IN3=1) THEN
a=7
DEBUG "7"
ELSEIF(IN1=1) THEN
a=8
DEBUG "8"
ELSEIF (IN5=1) THEN
a=9
DEBUG "9"

ENDIF

PAUSE 100
Raw4:

HIGH 4
LOW 6
LOW 7
LOW 2


' for row 4
IF (IN3=1) THEN
a=$2A
DEBUG "*"
ELSEIF (IN1=1)THEN
a=0
DEBUG "0"
ELSEIF(IN5=1) THEN
a=$23
DEBUG "#"
GOTO confirm
ENDIF
PAUSE 100
LOOP
confirm :
IF (a=1) THEN
GOTO second
ENDIF

second:
IF (a=2) THEN
GOTO correct
ELSE
GOTO show
ENDIF


correct:
DEBUG "Door Open"
PAUSE 2000
GOTO main ' the right password
show :
DEBUG "wrong password"
PAUSE 2000

sam_sam_sam
10-23-2010, 06:32 PM
Welcome to the Parallax Forum

You may want to try some like this


One VAR IN0
TWO VAR IN1

IF One = 1 THEN ' What ever you want to do

You may also want to try some like this

IF One = 1 THEN
IF Two = 1 THEN

' You code here

ELSE
IF it dose not match then what to next

This would give you the first two # 12

elyasfy
10-23-2010, 09:37 PM
thanx but this will not work i check it already

i need a sequence 124 for example using var

Mike Green
10-24-2010, 05:26 PM
Nuts and Volts Column #22 (http://www.parallax.com/tabid/272/Default.aspx) shows how to scan a 4x4 keypad and return a "key number". The same logic works for a 3x4 keypad.

A lot depends on how you want the keypad to behave. How does the user indicate that the password is beginning or ending? With a 3x4 keypad, the extra two keys are often used to indicate "clear" and "enter". Is that what you want? Do you want the keypad to timeout? In other words, clear itself after a specific period of time. Do you want to process the password as it's entered or wait for the whole thing to be entered before processing? What's the maximum number of digits in the password? Is the number of digits fixed? You need to say more about the kind of behavior you want for your password keypad.