joshnishikawa / MIDIcontroller

A library for creating Teensy MIDI controllers with support for hold or latch buttons, potentiometers, encoders, capacitive sensors, Piezo transducers and other velocity sensitive inputs with aftertouch.
223 stars 19 forks source link

easy way to incorporate this library with a button matrix? #8

Closed stonepreston closed 3 years ago

stonepreston commented 3 years ago

This library looks great! Glossing over the examples and it seems like the button objects are pretty much configured to be directly connected to a pin, is there a way to get things working with a matrix of buttons?

joshnishikawa commented 3 years ago

There's not currently an easy way to setup a matrix of buttons. It seems like there should be but there are a few different ways to wire up a matrix depending on what hardware you're using or whether multiple buttons on the same row/column should work at the same time etc. I've never actually made a button matrix but I'll try it when I get a chance. Hopefully I can come up with something simple enough to include in this library. Any info or insight is appreciated.

stonepreston commented 3 years ago

That would be awesome. I feel like any midi controller thats more than a few knobs and buttons would be using a matrix since it saves so many pins. I have not actually made one yet either haha but Ive done lots of research. For matrix scanning there is this keypad library that seems very easy to use to get a matrix up and running.

For general theory about button matrices the mechanical keyboard community has a wealth of resources. Here is a good overview of the matrix, and here is a nice guide on handwiring and different ways of soldering the diodes and what not.

joshnishikawa commented 3 years ago

It looks like the 'Keypad' library has button matrixes pretty well sorted out. It should be just a matter of writing a sketch that uses the Keypad library to send MIDI messages instead of key presses. It would be interesting to see a proof of concept. However, increasing the number of MIDI inputs is generally done with MUX chips as they are very cheap and simple to implement. I've added a sketch for muxed inputs to the examples.