Simple Keypade Interface
Hello All.
I have read the nuts and volts articles and web searched interfacing a keypad to the Basic Stamp 40 pin module. I need help. I do not understand. I have only taken basic electronics, and digital electronics in college. Those two classes 5 years ago got me interested in hobby electronics. I have some led displays shift registers and 7447s bcd to 7 seg decoders. What I need to do is adapt a keypad for entry into the shift registers.
I can understand a simple 12 "Button Keypad" each key wired to a common ground. What I don't understand is Matrix Keypads.
3x4, 4x4. I understand there are rows and columns. What is a matrix in this case? How does it work? Please use simple terms to help me understand. What would the code look like? I need it to output 4 bit binary nibbles into the shift registers.
How does a simple keypad work? I.E. The Button Command?
Again, I have read the nuts and volts but don't understand them, I am new at this. Please Help.
Thanks.
I have read the nuts and volts articles and web searched interfacing a keypad to the Basic Stamp 40 pin module. I need help. I do not understand. I have only taken basic electronics, and digital electronics in college. Those two classes 5 years ago got me interested in hobby electronics. I have some led displays shift registers and 7447s bcd to 7 seg decoders. What I need to do is adapt a keypad for entry into the shift registers.
I can understand a simple 12 "Button Keypad" each key wired to a common ground. What I don't understand is Matrix Keypads.
3x4, 4x4. I understand there are rows and columns. What is a matrix in this case? How does it work? Please use simple terms to help me understand. What would the code look like? I need it to output 4 bit binary nibbles into the shift registers.
How does a simple keypad work? I.E. The Button Command?
Again, I have read the nuts and volts but don't understand them, I am new at this. Please Help.
Thanks.

Comments
A "matrix" is the name of any unit or thing made of rows and columns. If you understand a 1x4 keypad with common ground:
then a 4x4 matrix keypad is just four of those.
I recently hoked up a 4x4 keypad, so this is my code which should more or less self explaining. Of course you will have to match the LOOKUP-table to your particular type of keypad.
For basic articles about how to connect all sorts of things I would suggest searching the nuts-and-volts articles, tracy allen's (emesys.com) articles, and last
but not least the BS manual.
Greetings
Adrian
' {$STAMP BS2} ' {$PBASIC 2.5} keymask CON $7f ' bit-& with keychar to decode character keychar VAR Byte ' key status and character keypress VAR keychar.HIGHBIT ' 1 if a key is pressed keypadr VAR keychar.HIGHNIB keypadc VAR keychar.LOWNIB Main: DO GOSUB KeypadScan IF keypress THEN keychar = keychar & keymask DEBUG ASC? keychar PAUSE 250 ENDIF LOOP END ' Scan a 4x4-Keypad: ' ' Vdd Vdd ' | | ' 10k < < ' > > ' 4 | | C ' INA/OUTA--/-----+---|---|-R ' 4 | | ' INB/OUTB--/---------+---+ ' ' use only 7-bit characters for character decoding as bit-8 is used to ' monitor key-pressed status. KeypadScan: keychar = 0 ' initialize DIRL = $0f ' columns in, rows out OUTA = $0 ' rows low keypadc = ~INB ' read column IF keypadc = 0 THEN KeypadScan_noKey DIRL = $f0 ' columns out, rows in OUTB = $0 ' columns low keypadr = ~INA ' read row IF keypadr = 0 THEN KeypadScan_noKey keypadc = NCD keypadc - 1 ' decode row/column keypadr = NCD keypadr - 1 keypadc = keypadc | (keypadr << 2) LOOKUP keypadc,[noparse][[/noparse] "+",".","0","C", ' decode to 7bit-character "-","3","2","1", "*","6","5","4", "/","9","8","7"],keychar keypress = 1 KeypadScan_noKey: DIRL = $00 ' all input RETURN