Hi- I was hoping that I could do both a 4x4 kb and an LCD with only one register. However, I do not think it is possible - although I wouldn't put it past some of the people on this list comig up with a solution. You need 4 outputs to scan the kb, and 4 inputs to read the kb. The LCD needs 4 bits data, a register select bit, and a control bit. As I see it, you start messing up the display if you try to multiple use the pins. Best I can do is one port and one extra line, so... CHALLENGE: can you scna a keyboard, and run an LCD display with only 8 pins/bits = 1 port -- without extra active hardware? David H Edson Brusque wrote: > Hello Adam, > > > The routine can be found in this C file: > > http://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 > 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 listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body