# 16 by 8 Keyboard matrix

I am working on a project, trying to construct an 80 button keypad. My problem is how to multiplex it so that i only feed the arduino with two sets of BCD or binary(whichever is easier) which are supposed to drive a 75 led display board simultaneously with a pair of 7 segments. The led display board is remote, which means i should drive the boards serially. The other 5 buttons remaining out of 80 are for other functions such as clear last number etc. Please help!

Thank you very much guys. To answer FuaZe, it is 16*8 but will not use the whole 128 buttons. These extra buttons are for future expansion. The input should consist 16colums and 8 rows. The remote output board is a led matrix numbered from 1 to 75, arranged in a 15colums and 5rows. The same display board is to have a two digit 7seg display. The remote board is to be accessed serially so as to use few cables. When I press a button on the matrix, say column 5 row 2 the number 20 should appear on the 7seg plus a correspondind diode on column 5 row 2 to light. In short if is a bingo board with numbers 1 to 75..

• Why is the name of the question: "16 by 8 keyboard matrix", 16*8 does not equal 80 buttons?
– Paul
Dec 22, 2015 at 13:55
• Yes, 16x8 = 128 as either 16 outputs multiplexed by 8 inputs, or vice versa, and maybe multiplexing the 75+2x7 segments as another 10 by 7. Seems like 16+8+10+7 = 41 pins it would fit easily on a 54 IO pin mega. Maybe you want a 80 button multiplexed input, along with multiplexed 8x10 and 7x2 outputs? Tell more about the remoteness requirement and the board vs boards requirements. Dec 22, 2015 at 19:54
• Ask your favorite internet finding service about "charlieplexing keys". This may help to connect more keys using less pins.
– gone
Dec 23, 2015 at 1:27

## 2 Answers

Easiest would be to use 2 arduino's, which are connected in some way. One of them should tell the other one what to do. I suggest you make the one reading the buttons the "master" and the other one it's "slave" device.

You could use 8 inputs, for each column and 10 outputs for each row. Then you check all 8 inputs per column (pretty rapidly) and then you'll be able to read every button.

You could choose to either send changes or just every value to the slave device.

The slave device would have to do something similiar, but with 2 outputs, to address the right LED's/segments.

Alternatively you could use shift-registers.

There actually are a lot of tutorials on this to be found on the web. You should check out "Arduino multiplexing" or "Arduino led cube" tutorials.

Another option would be using both shift registers and port expanders, like Adafruit's MCP23017 I2C Port Expander.

You can use that for the buttons, just get a few of them and hook them up on the I2C bus and you have over eighty pins for the price of 2! If you choose to use the previously stated expander, you will also benefit from Adafruit's library.

Then, use a shift register for your LEDs, using one of the pins that is not I2C.

Note: Pin expanders can handle input and output. Shift registers are only for output!

Good luck!

• Actually there are shift registers for input as well - such as the CD4021B by Texas Instruments: ti.com/product/CD4021B. It's widely supported (for example arduino library: arduino.cc/en/tutorial/ShiftIn) and has a 16 bit version as well Jul 26, 2020 at 13:12