Searching \ for '[PIC]: 4*4 keypad routine' 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/microchip/devices.htm?key=pic
Search entire site for: '4*4 keypad routine'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 4*4 keypad routine'
2002\02\08@030547 by Andrew Farrar

flavicon
face
<color><param>0100,0100,0100</param><FontFamily><param>Times New Roman</param>Hello,

I expect this has probably been discused before.

I am after ideas/code snippet really, my requirement is a fairly efficient
keypad routine (I have seen a few very long ones), which is NOT interrupt
driven.  My own bit of software will decide at what times it is appropriate to
scan the keypad.  My own software will have multiplexed display the time
period between outputting new display data may be used for keypad
debounced, so not worried about debounce, my bit of software will sort that
aspect out.


Really after ideas for subroutine that gets key value from a 4*4 keypad. (I
will sort debounce and when to scan).

Many thanks for any help that you give.

Cheers

Andrew Farrar

spam_OUTandrew.farrarTakeThisOuTspamport.ac.uk<FontFamily><param>Arial</param>

<nofill>

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\08@224018 by kben

picon face
Hi Andrew, have you tried >>>>
http://www.piclist.org/techref/microchip/keymatrix.htm

>I expect this has probably been discused before.
>
>I am after ideas/code snippet really, my requirement is a fairly efficient

>keypad routine (I have seen a few very long ones), which is NOT interrupt
>driven.  My own bit of software will decide at what times it is appropriate
to
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\08@231425 by M. Adam Davis

flavicon
face
The code I use (in C) is user run, and either falls through (returning
the key being pressed) or, by uncommenting one line, stays in the
routine until the key is released.

The routine can be found in this C file:
www.ubasics.com/adam/electronics/ha/ver000101/node.c
search for "char scankp(void)"

While it's designed for the radio shack 3x5 keypad it would not be
overly difficult to modify for a 4x4 scan.  The asm (with C code in
comments) is here:
http://www.ubasics.com/adam/electronics/ha/ver000101/node.asm

It returns the key press as a 4 bit number, 0-14 in this case.

-Adam

Andrew Farrar wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\02\09@005146 by Jeff DeMaagd

flavicon
face
Joan Ilari had a web page with a design for an integrated keypad and LCD
module, but I can't find it.

The keypad had 12 individual buttons that went into two parallel to serial
shift register chips - it only took two or three pins on the PIC.  It's
trivial to adapt that circuit to 16 buttons with just adding buttons, more
with adding more buttons, another chip and a moderate code tweak.

The keypad and LCD code are separate and the circuit designs aren't
intertwined either, I've used one, the other or both on my breadboard.

http://www.terra.es/personal4/joan.ilari/lcd/lcd.htm

That module likely won't work on matrix pads - each button needs its own line.

Jeff

At 08:04 AM 2/8/02 +0000, you wrote:
{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2002\02\09@100703 by Edson Brusque

face
flavicon
face
Hello Adam,

> The routine can be found in this C file:
> www.ubasics.com/adam/electronics/ha/ver000101/node.c
> search for "char scankp(void)"

   what I'm doing seens to be simpler. The routine on the bottom of this
email uses a 4x4 keypad in PORTB. ROWS are on RB3:RB0 and columns on
RB7:RB4. RB3:RB0 (outputs) is also the DB7:DB4 lines to the LCD. The code is
below and although it's a bit BIG in C, it could be made smaller in
Assembly.

   Best regards,

   Brusque

-----------------------------------
Edson Brusque
Research and Development
C.I.Tronics Lighting Designers Ltda
Blumenau  -  SC  -  Brazil
http://www.citronics.com.br
Say NO to HTML mail
-----------------------------------


/* **************************************** */
/* Sorry, no coments :)                     */
uns8 get_key_pressed(void)
{
uns8 key_buffer;

key_buffer = 0;

PORTB = 0b1110;
delay_cycles(5);
if (!PORTB.B4) key_buffer = '1';
if (!PORTB.B5) key_buffer = '2';
if (!PORTB.B6) key_buffer = '3';
if (!PORTB.B7) key_buffer = '4';

PORTB = 0b1101;
delay_cycles(5);
if (!PORTB.B4) key_buffer = '5';
if (!PORTB.B5) key_buffer = '6';
if (!PORTB.B6) key_buffer = '7';
if (!PORTB.B7) key_buffer = '8';

PORTB = 0b1011;
delay_cycles(5);
if (!PORTB.B4) key_buffer = '9';
if (!PORTB.B5) key_buffer = '0';
if (!PORTB.B6) key_buffer = 'A';
if (!PORTB.B7) key_buffer = 'B';

PORTB = 0b0111;
delay_cycles(5);
if (!PORTB.B4) key_buffer = 'C';
if (!PORTB.B5) key_buffer = 'D';
if (!PORTB.B6) key_buffer = 'U';
if (!PORTB.B7) key_buffer = 'E';

return key_buffer;
}

/* **************************************** */
/* This is a debounce sugestion, never used */
uns8 get_key_pressed_debounce(void)
{
if (get_key_pressed()) {
   delay_ms(50);
   return get_key_pressed();
}
}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\02\09@101115 by Edson Brusque

face
flavicon
face
Hello Jeff,

> The keypad had 12 individual buttons that went into two parallel to serial
> shift register chips - it only took two or three pins on the PIC.  It's
> trivial to adapt that circuit to 16 buttons with just adding buttons, more
> with adding more buttons, another chip and a moderate code tweak.

   I've done something similar using a pair of 4051s on a circuit I already
have another pair of 4051s to read from 16 pots. Just used two other PIC
inputs for keys the 4051 input-select lines are the same for all of them.

   Best regards,

   Brusque

-----------------------------------
Edson Brusque
Research and Development
C.I.Tronics Lighting Designers Ltda
Blumenau  -  SC  -  Brazil
http://www.citronics.com.br
Say NO to HTML mail
-----------------------------------

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


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