I'll check it out, though I would love to use the set of CD74HC4067 multiplexers that I have for a few different reasons. I will ultimately have three 61-key keyboards and additional switches to be controlled by my Arduino and was wondering if this code might do the trick. I wasn't sure if I needed to declare the pinMode for each multiplexer or if the ControlSurface package does that for me when instantiating a NoteButtonMatrix.
#include <Control_Surface.h> // Include the Control Surface library
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>
HairlessMIDI_Interface midi;
using namespace MIDI_Notes;
// Instantiate a multiplexer
CD74HC4067 mux_1{2, {5, 6, 7, 8} , }; //input, S0-S3, optional enable
CD74HC4067 mux_2{3, {5, 6, 7, 8} , }; //input, S0-S3, optional enable
const AddressMatrix<8, 8> addresses
{{
{36, 37, 38, 39, 40, 41, 42, 43},
{44, 45, 46, 47, 48, 49, 50, 51},
{52, 53, 54, 55, 56, 57, 58, 59},
{60, 61, 62, 63, 64, 65, 66, 67},
{68, 69, 70, 71, 72, 73, 74, 75},
{76, 77, 78, 79, 80, 81, 82, 83},
{84, 85, 86, 87, 88, 89, 90, 91},
{92, 93, 94, 95, 96, 97, 98, 99},
}};
NoteButtonMatrix<8, 8> matrix_I
{
{
// ROW PINS // INPUT // HORIZONTAL
mux_1.pin(0), mux_1.pin(1), mux_1.pin(2), mux_1.pin(3), mux_1.pin(4), mux_1.pin(5), mux_1.pin(6), mux_1.pin(7),
},
{
// COLUMN PINS // OUTPUT // VERTICAL
mux_2.pin(0), mux_2.pin(1), mux_2.pin(2), mux_2.pin(3), mux_2.pin(4), mux_2.pin(5), mux_2.pin(6), mux_2.pin(7),
},
addresses, // address matrix
CHANNEL_1, // channel and cable number
};
void setup()
{
mux_1.begin();
mux_2.begin();
for(int i=0; i<8; i++)
{
//do I need to assign inputs and outputs?
mux_1.pinMode(i, OUTPUT);
mux_2.pinMode(i, INPUT_PULLUP);
}
Control_Surface.begin(); // Initialize Control Surface
}
void loop()
{
Control_Surface.loop(); // Update the Control Surface
}
//Thanks to PieterP's example code
Thanks!!