Go Down

Topic: 4x6 button matrix. How do you read directly? (Read 785 times) previous topic - next topic

halkun

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!

Right?

Boffin1

There is a simple library  keypad.h to do this

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

halkun

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

...from this

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

to this

1,2,3,x  <-dead button
4,5,6,x
7,8,9,x
*,0,#,x
A,B,C,x
D,E,F,x

Which looks to be a better layout anyway :)

robtillaart

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 [del] button
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up