Pages: [1]   Go Down
Author Topic: 4x6 button matrix. How do you read directly?  (Read 671 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a simple library  keypad.h to do this
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 533
Posts: 26935
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! Keypad.h is exactly what I needed! and it tested out perfectly... Except I discovered one of my buttons were not working smiley-sad 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 smiley
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13663
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: