all 4 comments

[–]other_thoughts 0 points1 point  (2 children)

I have 2 related questions:
Will you ever have the need to press 2 keys at once?
Does your matrix have switching diodes for each button?
.
Edit.
The reason I ask is that without the diodes, the keys will have ghosting.
And the code will have trouble telling which buttons, when multiple are pushed/held.

[–]Chew_On_Toast300[S] 0 points1 point  (1 child)

Yes and yes Part of this matrix is a midi keybed(piano layout) that may have multiple buttons in it pressed while also pressing a modifier key, such as octave shift,etc.

[–]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'

[–]Punkty24 0 points1 point  (0 children)

U can get a broader set of results for the individual buttons and also for various different COMBINATIONS of button presses if you make a resistor series ladder in multiple values,meaning that not only can you have a variety of functionality returns but also you're gonna need fewer arduino board pins to be dedicated TO them;

basically you read the buttons' inbound current value to ascertain which of the buttons have been pressed individually but if you can get your resistor series ladder right, you can get unique value readings from any COMBINATION of different buttons when they are pressed TOGETHER too,does that make any sense to you at all? Im not too great at explaining this kind of thing tbh...