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
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!
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
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.
Comments
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!
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
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 Savage
Parallax Tech Support