I am planning to implement V-USB with an ATMega8 microcontroller. I am interested in implementing an HID device; more specifically, I want to try and make my own simple 26 key keyboard (each corresponding to a letter of the English alphabet).
This may be a stupid question, but do I need an input pin for each key I implement? In other words, will I need to use a microcontroller that has at least 26 I/O pins? Or is there another way to do this?
Answer
The idea to use a matrix is certainly the way to go. Your matrix could be organized in another way with eight input rows and four output lines for support of up to 32 switches. Since you only need to excite one input row at a time you could use a simple common 3-8 decoder to drive the input rows like shown below. This reduces the total microcontroller pin count to 7 lines!!
Note that with use of a 74HC138 type of 3-8 decoder it is necessary to flip the logic so that the output columns have pullup resistors, the diode direction is inverted and the software will see lows (0's) on the output lines where detected switches are seen.
Many thanks to tcrosley for borrowing some of his key matrix graphics and to Philips Semiconductors for the logic symbol image of their 74HC138 part.
No comments:
Post a Comment