navaru
asked on
Interface a 4x4 keypad with a PIC
I want to add a 4x4 keypad to a 16F877A, i've made the connections to the pins but I don't know how to decode/write the ASM code.
What I want to do is: when I press 3 on the keypad the PIC will scan the keypad and figure it out it was the '3' key and load it in a variable.
So far I wrote the code for:
; RB4 RB5 RB6 RB7
; COL1 COL2 COL3 COL4
; RB0 ROW1 1 2 3 A
;
; RB1 ROW2 4 5 6 B
;
; RB2 ROW3 7 8 9 C
;
; RB3 ROW4 * 0 # D
Setting the pins to the wires.
How to intercept the key pressed ?!
I couldn't find anything on the net that will explain the logistic or how is done step by step.
Could anyone help with a source code explained or some good documentation?
Thanks for your time!
What I want to do is: when I press 3 on the keypad the PIC will scan the keypad and figure it out it was the '3' key and load it in a variable.
So far I wrote the code for:
; RB4 RB5 RB6 RB7
; COL1 COL2 COL3 COL4
; RB0 ROW1 1 2 3 A
;
; RB1 ROW2 4 5 6 B
;
; RB2 ROW3 7 8 9 C
;
; RB3 ROW4 * 0 # D
Setting the pins to the wires.
How to intercept the key pressed ?!
I couldn't find anything on the net that will explain the logistic or how is done step by step.
Could anyone help with a source code explained or some good documentation?
Thanks for your time!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Easy.
First of all, I suggest you use c rather (if you don't know asm)
You have 2 options:
option1: read the "interrupts" section spec of the pic. Implement a signal change interrupt.
option2: it is easier to just have an infinit loop (no interrupt) that scans the keyboard.
Note: I know from my experience that the fastest click of a button will change the signal for at least 40ms. so this is quite safe.
still you need either a hardware or a software debouncer.
Do it in software. It's much easier.
First of all, I suggest you use c rather (if you don't know asm)
You have 2 options:
option1: read the "interrupts" section spec of the pic. Implement a signal change interrupt.
option2: it is easier to just have an infinit loop (no interrupt) that scans the keyboard.
Note: I know from my experience that the fastest click of a button will change the signal for at least 40ms. so this is quite safe.
still you need either a hardware or a software debouncer.
Do it in software. It's much easier.
ASKER