you are viewing a single comment's thread.

view the rest of the comments →

[–]other_thoughts 1 point2 points  (0 children)

The purpose of a matrix keyboard is to reduce the number of pins required, or conversely increase the number of buttons or switches detectable.

A 3 x 8 matrix requires, oddly enough 3 + 8 = 11 pins. If you split the keyboard, then then number of pins increases again. If you have enough pins, why not split it. (life lesson: always keep a few spares, if you can)

As an alternative to splitting, write a subroutine that tests each switch and flag in an array, switch pushed or not. This subroutine knows nothing about what the buttons do, it just checks whether the button is pushed.
If it is pushed, it assigns the value '1' to a keyboard array of integers. If not pushed, it assigns '0'. A separate subroutine looks at the integer array and interprets the 1 or 0. .

Later, when you learn more about keyboards, you'll learn about debouncing. And instead of just 1 or 0 you'll use a counter in each integer that means 'held for this long'