Control-Surface
Control-Surface copied to clipboard
Digital i/o two (4067 Mux) 61 keys
Hi. is there a version or a sample code that has a digital i/o for multiplexers (4067) goal is to do a basic 61 keys midikeyboard. can't seem to find the matching codes from the codes.
61 keys 8x11 scan matrix 2 (4067 multiplexers)
// Your code here
#include <Control_Surface.h>
#include <Arduino_Helpers.h> // Include the Arduino Helpers library
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>
#include <MIDI_Outputs/NoteButton.hpp>
#include <MIDI_Senders/DigitalNoteSender.hpp>
USBMIDI_Interface midi;
using namespace MIDI_Notes;
///////////////////////////////////////
// Instantiate a multiplexer
CD74HC4067 mux_1 {2, {5, 6, 7, 8} }; // INPUT PIN // Address pins S0, S1, S2, S3
CD74HC4067 mux_2 {3, {5, 6, 7, 8} }; // INPUT PIN // Address pins S0, S1, S2, S3
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},
}};
//CONTROL ELEMENTS//
NoteButton midinotes[]{
{mux_1.pin(8), {MIDI_Notes::C(2), CHANNEL_1}},
{mux_1.pin(9), {MIDI_Notes::Db(2), CHANNEL_1}},
{mux_1.pin(10), {MIDI_Notes::D(2), CHANNEL_1}},
{mux_1.pin(11), {MIDI_Notes::Eb(2), CHANNEL_1}},
{mux_1.pin(12), {MIDI_Notes::E(2), CHANNEL_1}},
{mux_1.pin(13), {MIDI_Notes::Gb(2), CHANNEL_1}},
{mux_1.pin(14), {MIDI_Notes::Gb(2), CHANNEL_1}},
{mux_1.pin(15), {MIDI_Notes::G(2), CHANNEL_1}},
};
void setup()
{
mux_1.begin(); // Initialize multiplexer
mux_1.pinMode(2, OUTPUT); // Set the pin mode (setting it for one pin of
// the multiplexers sets it for all of them)
mux_2.begin();
mux_2.pinMode(3, INPUT_PULLUP);
Control_Surface.begin();
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}