Shop OBEX P1 Docs P2 Docs Learn Events
need help with password code — Parallax Forums

need help with password code

CMMBCMMB Posts: 3
edited 2007-12-07 15:42 in BASIC Stamp
im currently on the final leg of my project.· im having troubles with writing a password code for a 4-digit password. i fabricated my own key pad heres the code attatched below.· please help with idea's
thanks

Comments

  • metron9metron9 Posts: 1,100
    edited 2007-12-06 16:23
    Your code falls through and defaults to run display1: in the event 1n2..in11 are all 0 in the main loop. I assume your lookup tables would be different numbers and you are testing with default numbers for debugging but I would make all of the display routines into one large lookup table. Get the key 1..9 and then add an index of 9 for each display so you have a double demention array lookup table. that will save the space for all of the additional commands as they are redundant.



    something like:

    if IN1=1 then keys=keys+0
    if IN2=1 then keys=keys+9
    ...
    ...

    Lookup keys [noparse][[/noparse]1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9... and so on so all 9 keys are in one lookup table

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • CMMBCMMB Posts: 3
    edited 2007-12-06 18:06
    thanks for the info Metron9 but we cant get that to work, and we still dont have a way for it to have a passcode.

    heres what we have:

    workspace VAR Byte
    keys VAR Nib
    result VAR Byte
    Delay CON 255



    SEROUT 1, 84, [noparse][[/noparse]254]
    SEROUT 1, 84, [noparse][[/noparse]88]





    main:
    IF IN2 = 1 THEN keys=keys+1
    IF IN3 = 1 THEN keys=keys+2
    IF IN4 = 1 THEN keys=keys+3
    IF IN5 = 1 THEN keys=keys+4
    IF IN6 = 1 THEN keys=keys+5
    IF IN7 = 1 THEN keys=keys+6
    IF IN8 = 1 THEN keys=keys+7
    IF IN9 = 1 THEN keys=keys+8
    IF IN10 = 1 THEN keys=keys+9

    LOOKUP keys, [noparse][[/noparse]1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9] , result
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-12-06 20:09
    Its possible the routine is looping around and reading the same key press more than once, you could use a loop to debounce the switches like the following

    keys VAR Word

    Main_Loop:

    DO
    keys=INS & 2044
    LOOP WHILE keys=0

    DEBUG HOME,? keys

    DO
    keys=INS & 2044
    LOOP WHILE keys<>0
    PAUSE 500

    GOTO Main_Loop

    the DEBUG will give a number for each key that can be used in a LOOKDOWN table then used with ON_GOSUB. The instruction keys=INS & 2044 monitors P2 - P10.

    Jeff T.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-12-07 15:42
    I have posted example password code before, however the examples do make use of keypad decoder chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.