Wing Kent Kwan appears to have written: > how can I only uses 5 cpu I/O pin for 16 keyborad keys input? > My means is No use IC to do it! > only use the diodes to do it? but I don't know how to connected it? Fairly simple. Each key goes to ground, each CPU line has a pull-up. Each diode in the matrix goes anode to CPU pin, cathode to key. Ten keys have two diodes each to a pair of CPU pins, there are 5c2 or 10 (= 5 x 4 / 2) such combinations. Ten more keys could have three diodes each to CPU pins (5c3 = 5 x 4 x 3 / 3 x 2 .. consider it as each *not* going to 2 CPU pins out of the five). Remember you will need a *good* debounce routine for this, it is *zero*-key rollover IOW two keys pressed simultaneously will quite possibly show as a third, different key. You will probably want to save on diodes by using all two-diode and only six three-diode key encodings, total 38 diodes. I feel it is somewhat more reliable than a single-line encoding. Of course if you allowed anywhere from one to five diodes per key, you can encode 31 keys. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 A x x x x x x x x x x B x x x x x x x x x x C x x x x x x x x x x D x x x x x x x x x x E x x x x x x x x x x Frankly, I think it would be simpler and easier to use a shift register or counter... -- Cheers, Paul B.