Searching \ for 'MEL Basic and matrix keypad..' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/language/index.htm?key=basic
Search entire site for: 'MEL Basic and matrix keypad..'.

Truncated match.
PICList Thread
'MEL Basic and matrix keypad..'
1997\08\05@143956 by Kevin J. Slater

picon face
Has anyone worked with MEL's Basic compiler to develop code to read the
keypresses on a
matrix keypad? I'm thinking of tackling a garage door keypad with some
additional features. I'm
not into PIC's enough to attempt ASM code for this project. Alternately, can
anyone suggest an IC
that could be used to read the keypad and present the key pressed to a PIC pin?

Any help greatly appreciated..

...Kevin


/* Kevin Slater */
/* Slater Programming Services */
/* Mars, Pa. 16046-3938 */
/* http://www.pobox.com/~kslater */

1997\08\05@160431 by Mike Keitz

picon face
On Tue, 5 Aug 1997 14:30:44 +0500 "Kevin J. Slater" <spam_OUTkslaterTakeThisOuTspamFYI.NET>
writes:
>Has anyone worked with MEL's Basic compiler to develop code to read
>the
> keypresses on a
>matrix keypad? I'm thinking of tackling a garage door keypad with some
> additional features.

Reading a matrix keyboard is not too complicated.  One dimension of the
keyboard (for example, the columns) will be connected to processor
outputs.  I'll call these the "scan" lines.  The other dimension is
connected to processor inputs.  These are the "return" lines.  For
example, a telephone type keyboard could be:
S0 S1 S2
1  2  3 - R0
4  5  6 - R1
7  8  9 - R2
*  0  # - R3

The return lines need pull-up or pull-down resistors so if no keys are
pressed they will read as inactive.  If it is expected that more than one
key will be pressed at a time, it is necessary to use a diode at each key
to prevent multiple paths through the matrix.  To read the keyboard, make
one scan line at a time active, wait a (very) short time for the signals
to settle, and read the return lines.  Repeat the process with the other
scan lines.  Store each return result as an entry in an array.  In this
case, the array is 3 elements of 4 bits each.  If all the array elements
are 0, no keys are pressed.  Any 1 bits correspond to keys that are
pressed (without diodes, multiple keypresses won't read correctly
though).  The result in the array is the instantaneous "state" of the
keyboard.  The scanning should be done about once every 40-50 ms.  Done
too fast, keys bouncing will be interpreted as multiple presses.  Too
slow, and the user will need to press each key for what seems to be a
long time before it is recognized.

Usually it is desired to act only when a key is first pressed.  For
example, pressing key 3 should enter "3" in a buffer, but only once until
the 3 key is released and pressed again.  To do this, the previous state
of the keyboard needs to be stored and compared to the new state.  After
comparing, new would be copied into previous for next time.  The
comparison looks for previous =0, and new = 1.  This can be done by
bitwise complementing previous and bitwise anding it with new.  If any
bits in this result are 1, they identify newly pressed keys.  This result
would be 12 bits but only one bit is 1.  Probably the best way to decode
this to a key number would be to shift it until the first 1 is found, and
use the number of shifts to look up in a table the key value.

1997\08\06@164403 by Mike Ghormley

flavicon
face
Kevin J. Slater wrote:

<snip>

> Alternately, can anyone suggest an IC that could be used to read the keypad
and
> present the key pressed to a PIC pin?

I have used the 74C922 & 74C923 chips which scan a 16-key or 20-key
(respectively)
keypads.  They are pricey at $13.13 US for ones at Digi-Key, but drop to $5.625
in
hundreds.  They work well handling all the scanning, rollovers, and generating
an INT
signal on keypress.  Four data lines plus some control line overhead and two
caps.

I always buy the `923's as they are the same price as the `922's.

Michael

When the way of the Tao is forgotten, kindness and ethics must be taught.
Men must learn to pretend to be wise and good.  --  Lao Tzu

1997\08\06@181508 by Philip Restuccia

flavicon
face
> Kevin J. Slater wrote:
>
> <snip>
>
> > Alternately, can anyone suggest an IC that could be used to read the keypad
>  and
> > present the key pressed to a PIC pin?
>
> I have used the 74C922 & 74C923 chips which scan a 16-key or 20-key
>  (respectively)
> keypads.  They are pricey at $13.13 US for ones at Digi-Key, but drop to
$5.625
>  in
> hundreds.  They work well handling all the scanning, rollovers, and generating
>  an INT
> signal on keypress.  Four data lines plus some control line overhead and two
>  caps.
>
> I always buy the `923's as they are the same price as the `922's.
>
> Michael

Michael:

You may want to check Jameco instead .., I believe they charge $5.95 for each.

       Philip Restuccia
       .....philip.restucciaKILLspamspam@spam@peri.com

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...