4x6 button matrix. How do you read directly?

Hi there... I have a 4x6 button matrix that leads out to a 10 pin ribbon cable. I have the datasheet and how it works is each button closes two of the leads on the ribbon cable so you can see which button was pressed.

How would you read the buttons if you plug it directly into the Arduino's digital pins? I can't seem to figure out how to "sense" a closed circuit. Do I fire +5v down one pin and see which line it comes out on? If nothing comes out with voltage on the first pin, then cycle down each of the leads until I get voltage coming back? For example on a 4 lead ribbon cable I do this...

|||| +--- Nothing

|||| -+-- Nothing |||| --++ Ah! I fire +5 down 3 and I get it back on 4, meaning that pins 3 and 4 are "shorted" and therefore button x is pressed!


There is a simple library keypad.h to do this

Your understanding of the multiplexing is correct. The Library may have internal pullups on all the pins. Perhaps a column is pulled low, the rows are read, a sensed low row combined know column low = known button pressed.

Thanks! Keypad.h is exactly what I needed! and it tested out perfectly… Except I discovered one of my buttons were not working :frowning: Not a total loss as I wasn’t planning on using them anyway. (They were extras just in case) It was moved…

…from this


to this

1,2,3,x <-dead button

Which looks to be a better layout anyway :slight_smile:

I prefer the second layout ,

but you can rotate the pad 90 degrees getting a 6 x 4 layout

1 2 3 A B C
4 5 6 D E F
7 8 9 x x x
* 0 # x x x

what do you think of that?

One of the six could be a [reset] or a button