logIt Log Around The Clock

Any m-by-n Matrix Keypad for Raspberry Pi

What about instantiating any m x n matrix keypad by a Python class? Raspberry Pi takes me to learn how to build a Python class for the first time while expanding my initial WiringPi-based matrix keypad into a derivative work.

A matrix keypad instance is defined by:

  1. Actual GPIO pins used forming the row and column of the m x n matrix
  2. Individual character in-use as symbol for each button

Hence, I instantiate and call method like

...
QPad  = matrixQPi(keyPad=keyPad,row=row,col=col)
print QPad.scanQ()

to print the character being pressed. Some examples pushed to my github explains how the above keyPad, row, and col are defined to scan-read pressed button of 2×2, 2×3, and 4×3 matrix keypads .

Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols & GPIO combinations

Illustration of any m-by-n matrix: 4x3, 2x2, and 2x3 keypad with different button symbols & GPIO combinations

I used deprecated Wiring-Pi Python (they already moved to 2.x version) without problem. However, you’ll fail building from latest commit and must use combination of older commits as described by my updated part of an old-post. By the way, there’s I/O expander support for WiringPi2-Python which is good, considering:

GPIO is expensive and for the sake of a keypad, you should not spend all.

(A friend told me that once)


Leave a Reply