Keypad on porta 18f1220

Status
Not open for further replies.
Ok the code reads the keys right It save them in a array. What I don't know is how to check them. Key(4) is the array holding my four key presses.
1. press key1 value placed in Key(4) and counter gos from 0
2. press key2 value added to next block of Key(4) counter 1
3. press key3 value added to next block of Key(4) counter 2
4. press key4 value added to next block of Key(4) counter 3 hits three all done
Now how can I get each value 1 at a time so I can check what keys have been pressed. I can send it out to a display and it tells me what four keys where pressed
works but not what i need to do. I tried this
Code:
    a = Key(Counter) -1 // gives me key 3 value
but it don't work for key 2 or 1 how do you get each.
I read that you can check each by using the step -1 but I couldn't get that to work Like this
Code:
for Counter = 3 to 0 step -1
// I don't no what you would put here 
next
I'm not good at writing wish I was better maybe you can see what I'm saying thanks
 
Last edited:
You can just do a=Key(0) to get key 1 through to a=Key(3) for key 4.

Edit, I now see how the key code works.

Mike.
 
Last edited:
This is what I have done I got the keypad module working on porta it was made for portb
I hooked 8 leds to portb to see what each key output value is and each lights the Binary value from 1 to 12. I haven't tried it like that thanks I'll jive it a shot Mike your the man.
Code:
Counter = 0
       For Counter = 0 To 3                   // checks  key2 after pressing all four 
            a=Key(1)
            portb = a
           DelayMS(500)      
       Next
I was close I tried it like this
Code:
Counter = 0
       For Counter = 0 To 3                   // swordfish keep saying you can't do it that way lol
            Key(1)=a
            portb = a
           DelayMS(500)      
       Next
thanks agin Mike it worked just like I need it to this was killing me lol
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…