Peter Reynolds wrote: > > Dear All > > You must forgive me if this seems to be a very basic question, but I am > having trouble working out this concept. I know that it is possible to scan > a 4x4 keypad using 4 inputs and 4 outputs of, for example a 16F876. What I > am having trouble with is wheter it is better to use interrupts, or just a > straight scanning regime. Can anyone give me some advice on this, please? > > It sounds to me the problem you have is when to check for key press and how many times and how to tie the scanning into the rest of the program? Best is not to initially scan the keypad everytime to get keypress. Call a subroutine where you make all the scan lines high, then read the inputs to see if any of them is high (or set) This takes up minimum steps. If any is, then you start scanning to see which key it is. If not return to rest of program. Or as you say, use the interupt of portB and then run key scanning in the interupt routine. Just leave all your scan lines high (or set) though. The choice is yours depending if you want to interupt your program and at what level. First example gives you more control but the second is more automatic. Quentin -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu