Shop OBEX P1 Docs P2 Docs Learn Events
set the password using keypad 3x4 — Parallax Forums

set the password using keypad 3x4

elyasfyelyasfy Posts: 2
edited 2010-10-24 09:26 in Learn with BlocklyProp
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

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-10-23 10:32
    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
  • elyasfyelyasfy Posts: 2
    edited 2010-10-23 13:37
    thanx but this will not work i check it already

    i need a sequence 124 for example using var
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-24 09:26
    Nuts and Volts Column #22 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.
Sign In or Register to comment.