> 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
spam_OUTlistservTakeThisOuT
mitvma.mit.edu with SET PICList DIGEST in the body