Hi Josh, For debouncing see http://www.dattalo.com/technical/software/pic/vertcnt.html ... This has got to be the best way to debounce switches I have ever seen - ingenious. Works great. (Thanks Scott!) For 20 years I used to do the "take 3 samples and compare - when they all match you are debounced". Scott's way is far more elegant and faster. I now use a 2-bit vertical counter updated every 10mS to debounce 8 inputs at a time. Works great. Can you use a I/O port with internal pullups? Any way you slice it you will need 11 I/O lines (or more external hardware). I would lean toward driving one of 3 pins (in turn) and reading in 8 switches at a time. Others may point out valid reasons for doing something different though. -Mark > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf > Of Josh Koffman > Sent: Saturday, April 09, 2005 12:03 PM > To: Microcontroller discussion list - Public. > Subject: [PIC] Matrix Keyboard Philosophy > > > I'm going to be starting a project coming up using a preexisting > keyboard assembly. It has a non symmetrical matrix though - it's not > 4x4, it's 3x8 (if memory serves...it's not right in front of me at the > moment). With a 4x4, it's easy to drive 4 of the pins and scan the > other 4. But with a non symmetrical keyboard, would it be more > efficient to drive the 3 pins or the 8 pins? My thoughts are that if I > drove the 8 pins and watched the 3 pins, I'd need less pullup > resistors (useful as board space is limited). I'll sacrifice code > simplicity though, and it'd take 8 scans to read the whole keyboard. > But I only have to watch 3 pins which might be easier. > > Any thoughts on the matter? > > Also, I'm looking to implement a debouncing routine so that eventually > I will be able to trigger a command on the key down and the key up. My > idea so far has been to read the keyboard, and shift the result for > each key into a temp register, then look for patterns (ie 11110000 is > a keypress, 00001111 is a key release...we discussed this a few months > ago). This requires two steps though, reading the keyboard, then > comparing all the temp registers to the patterns. Anyone have a better > way? > > Thanks! > > Josh > -- > A common mistake that people make when trying to design something > completely foolproof is to underestimate the ingenuity of complete > fools. > -Douglas Adams > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist