Discussion in 'Microcontrollers, Programming and IoT' started by pyro009, Feb 19, 2013.

1. pyro009

2
0
Feb 19, 2013
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 ?

2. Harald KappModeratorModerator

11,446
2,628
Nov 17, 2011
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?

3. KrisBlueNZSadly passed away in 2015

8,393
1,271
Nov 28, 2011
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.

4. donkey

1,293
56
Feb 26, 2011
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

5. CocaCola

3,635
5
Apr 7, 2012
Micro pin pulled high ---- button --- Ground

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

6. donkey

1,293
56
Feb 26, 2011
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

7. CocaCola

3,635
5
Apr 7, 2012
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...

File size:
3.7 KB
Views:
252
8. donkey

1,293
56
Feb 26, 2011
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

9. CocaCola

3,635
5
Apr 7, 2012
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...

10. donkey

1,293
56
Feb 26, 2011
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

11. pyro009

2
0
Feb 19, 2013
Thanks guys. Appreciate the help