Maker Pro
Maker Pro

Matrix circuit for Keypads

pyro009

Feb 19, 2013
2
Joined
Feb 19, 2013
Messages
2
Hi,
In a recent embedded systems class we were briefed on the addressing mechanism of a matrix keypad. The keypad we used is a 2x2 keypad for 4 buttons.
My question is, why not use a 1x4 keypad? wont it reduce the no. of lines ?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,720
Joined
Nov 17, 2011
Messages
13,720
No, it won't.
1x4 keypad: 1 common + 1 line per key (4) = total 5
2x2 keypad: 2 rows+2 columns = total 4

With 4 keys on the keypad, the difference may not be worth the effort of multiplexing the matrix - unless you run out of port pins of the microcontroller.

The example given to you was probably only to explain the principle.
Consider a 64 key keypad: The ratio then is 65 lines vs. 16 lines (8 rows, 8 columns).

You see?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
In the case of a 4-button keypad, arranged as 4x1, there's no need for an I/O pin to drive the "1". It can just be tied to ground, and only 4 inputs are needed. So it works out the same. But as Harald said, the principle applies to keypads with more buttons. A keypad with 6 buttons or more will require less I/O if it's multiplexed.
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
hey kris why woldn't the 1 key need an I/O pin? every switch needs 2 connections, 1 ground and 1 other. if button 1 doesn't have a ground then how does it work?
just trying to figure this out in my head thats all I just can't see it having less than 5 ifin a single row
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
hey kris why woldn't the 1 key need an I/O pin? every switch needs 2 connections, 1 ground and 1 other. if button 1 doesn't have a ground then how does it work?
just trying to figure this out in my head thats all I just can't see it having less than 5 ifin a single row

Micro pin pulled high ---- button --- Ground

No need to matrix toggle the ground pin in a 4x1 arraignment...
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
ok.... that doesn't help I will figure it out eventually but thanks coca for putting me on the path to find out how to do it
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Look at the attached photo, it's reverse logic of what we were talking but the same truths hold...

As you see in a 4x2 matrix you check the keys like this...

All rows input
Both columns logic 0
Toggle column one to logic 1
Scan Row 1-4 to see if any of them are pressed
Toggle column one back to logic 0
Toggle column two to logic 1
Scan Row 1-4 to see if any of them are pressed
Loop

Thus you need the columns tied to I/O lines so that can change their state as you progress across them while scanning...


But in a 4x1 matrix you never need to toggle the column to scan all the keys, just tie column one to logic 1 permanently, no need to use an I/O line to do this as there is no progression across the columns as there is only one...

7305d1361334910-matrix-circuit-keypads-matrix.gif
 

Attachments

  • matrix.gif
    matrix.gif
    3.7 KB · Views: 252

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
ok coca let me put it this way, while trying to reformat an sd card for my computer I formatted the wrong drive and lost 2 terrabytes of info..... and to top that off when I got the thing formattedsomethingwentwrong andnowI cant find the sdcard.... can you tell my mind is kinda not with it today? lol
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
If you just formatted the drive the data is 100% recoverable without much hassle, you just need to rebuild the file index (if it was a quick format) or you recover the files to another drive and build a new index if it was a full format, there are plenty of programs to do this, some freeware... That is unless you tampered with it further...
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
yeah i know that but is it worth the effort? lol I am trying to get this freaking sd card fixed at the same time and no go.. anyway I hijacked a threadwhich I hate doing I will move this to off topics
 
Top