PDA

View Full Version : keypad?



jonas2
- 13th August 2009, 09:32
Hello

I have a problem with this program for managing a keypad.
when I press a key such as 1, it displays "1111" when I
supported once the?

thank you

Archangel
- 13th August 2009, 22:19
Hello

I have a problem with this program for managing a keypad.
when I press a key such as 1, it displays "1111" when I
supported once the?

thank you
Hi Jonas2,
I see 2 things I question:
1. IF i = 4 THEN GOTO confirm ' code complet ? oui confirme
0 to 3 so it should be complete @ 3

2. You are exiting a for next loop in a rude fashion. I would tell the loop row = 3 and then gosub. IMHO
Like so


FOR row = 0 TO 3 ' 4 rows in keypad
PORTB = 0 ' All output-pins low
TRISB = (DCD row) ^ $ff ' Set one row pin to output
col = PORTB >> 4 ' Read columns
IF col != $f THEN row = 3 ' If any key own, exit
NEXT row
Gosub gokey
return

It just clears the stack. AND Maybe your pause 100 is faster than your key finger too :D

jonas2
- 14th August 2009, 09:22
Hi

Yes, but the variable code0 has 1, 2 account code1, code2 account 3 code 3 has 4
IF i = 0 THEN
code0 = 1 >>>>> xkey
endif

IF i = 1 THEN
code1 = xkey >>>>>> 2
endif

IF i = 2 THEN
code2 = xkey
endif

IF i = 3 THEN
Code3 = xkey >>>>>> 4
endif

PAUSE 50

i = i + 1
IF i = 4 THEN GOTO confirm

So it is, I think the problem comes from the relaxation of the?