Keypad on porta 18f1220
Posted: Sat Apr 25, 2009 5:12 am
I was trying to save the first 4 key presses I have the keypad module working on PortA
It works find I put 8 leds on PortB and the value of the led is output to PortB It give the value 1 to 12 just like It should
This is the thing if I test to see if the key pressed It doesn't keep but the las one. Maybe you can tell me
what I'm doing wrong
This put the same value in all not what I want. Maybe some way to put four new key presses in a,b,c,d I hope so.
I done this 100 ways and no go LOL. thanks
It works find I put 8 leds on PortB and the value of the led is output to PortB It give the value 1 to 12 just like It should
This is the thing if I test to see if the key pressed It doesn't keep but the las one. Maybe you can tell me
what I'm doing wrong
Code: Select all
Device = 18F1220
Clock = 8
Config OSC = INTIO2
Config MCLRE = OFF
Include "INTOSC8.bas"
Include "Utils.bas" // local duty variable...
#option KEYPAD_PORT = PORTA
Include "Keypad12.bas"
Dim Key As Byte
Dim a As Byte
Dim b As Byte
Dim c As Byte
Dim d As Byte
SetAllDigital
TRISB =%00000000
PORTB =%00000000
Key = 0
a = 0
b = 0
c = 0
d = 0
While True
If Keypad12.Value <> 0 Then
Key = Keypad12.Value
EndIf
If Key >0 Then // test to see if a key was pressed
Debounce
a = Key
// should make a have the value of key and put it in a
EndIf
If Key >0 Then // test to see if a key was pressed
Debounce
b = Key
// should make a have the value of key and put it in b
EndIf
If Key >0 Then // test to see if a key was pressed
Debounce
c = Key
// should make a have the value of key and put it in c
EndIf
If Key >0 Then // test to see if a key was pressed
Debounce
d = Key
// should make a have the value of key and put it d
EndIf
If a = 1 And d = 4 Then
PORTB = d
EndIf
Wend
I done this 100 ways and no go LOL. thanks