PDA

View Full Version : very basic matrix keypad question



kitcat
- 8th July 2006, 19:02
I am trying to work out how to scan a 3 x 4 matrix keypad using porta 0-2 and portB 0-3. The reason is that I am using portb 6 & 7 for ICSP so I consider that they are not really available. I am a bit new to this so please bear with me.
Am I right in thinking that I need to pull porta pins high with pullup resistors, set portb 0-3 high and then take each portb pin low one at time and read the port a result? Is that how it works? Do I need pull up resistors on portb 0 - 3? I am using a 16f627

Thanks

mister_e
- 8th July 2006, 21:33
there's many different way to do a keyboard scan.. it's up to you to decide how to. There's few example here and there who show you how the author think. You can even use only one single pin using a a/d input. I/O expander, dedicated IC... list is long enough.

Now, there's no real problem using the ICSP pin as long as you respect the ICSP convention stated in the Microchip ICSP guide.

few months ago i posted a copy/paste solution bellow.
http://www.picbasic.co.uk/forum/showthread.php?t=3250

just make sure you disable the analog comparator on PORTA and you should be in business.

Need more info?
http://www.melabs.com/resources/samples/x1/pbp/keyx.bas
http://www.rentron.com/serkey16.htm
http://www.rentron.com/PicBasic/crosspoint.htm