Another midicontroller, Control Surface

Hey there, noob here.

As im not a c++ programmer i have kinda trial-and-error(ed) my way thru here. My compact midi controller is working ok but i feel im wasting inputs and thought id check with you folks if you had any ideas.

(one button is missing)

Heres the code:

#include <Control_Surface.h>
#include <AH/STL/algorithm> // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(6);
// Create a new bank selector that changes the bank setting of the bank we just
// created.
// It has push buttons connected to pins 21 and 20 that increment or decrement
// the bank setting, and 4 LEDs to pins 46, 48, 50, 52 that display the current
// bank setting.
IncrementDecrementSelectorLEDs<4> bankSelector {
  {0, 1},         // button pins
  {2, 3, 4, 5}, // LED pins
using namespace MIDI_CC;
Bankable::CCPotentiometer potentiometers[] {
  {{bank, BankType::CHANGE_CHANNEL}, A0, {Sound_Controller_1, CHANNEL_1}},
  {{bank, BankType::CHANGE_CHANNEL}, A1, {Sound_Controller_2, CHANNEL_1}},
  {{bank, BankType::CHANGE_CHANNEL}, A2, {Sound_Controller_3, CHANNEL_1}},
  {{bank, BankType::CHANGE_CHANNEL}, A3, {Sound_Controller_4, CHANNEL_1}},
  {{bank, BankType::CHANGE_CHANNEL}, A8, {Sound_Controller_5, CHANNEL_1}},
  {{bank, BankType::CHANGE_CHANNEL}, A9, {Sound_Controller_6, CHANNEL_1}},
Bankable::NoteButton muteButtons[] {
  {bank, 6, 0x14},
  {bank, 7, 0x15},
  {bank, 15, 0x16},
  {bank, 14, 0x17},
  {bank, 16, 0x18},
  {bank, 1, 0x19},
constexpr pin_t ledPin = 22;
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
void setup() {
  pinMode(ledPin, OUTPUT);
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
void loop() {
  // Function that checks if a given button is pressed
  auto checkButtonPressed = [](const Bankable::NoteButton &button) {
    return button.getButtonState() == Button::Pressed;
  // If any of the push buttons is pressed
  bool pressed = std::any_of(std::begin(muteButtons), std::end(muteButtons),
  // Turn on the LED
  digitalWrite(ledPin, pressed);

Im using:
6 analog inputs for my pots
6 digital inputs for buttons
2 digital inputs for buttons (bank selection)
4 digital inputs for LEDs (shows what bank is selected

Right now im using "NoteButton" class to make the buttons latch (works in ableton with notes but not with CC), but this uses one input per button. I was thinking of using "CCButtonLatched" class instead and combine it with a button matrix but im not sure how to make it bankable nor make it a matrix (in software/code).

using Control Surface library by tttapa:

Using this as a template:

Template for notebutton matrix:

For midi hex variables refere to:

Any ideas or help is appreciated.

ps, please allow some errors in terminology etc, sorry :slight_smile:

take care

You are not wasting inputs.
You can connect every button to its own pin, or you can put the buttons in a matrix and maybe use less buttons. Both are okay.

if i use matrix i think i can use more buttons, 1 pin per row. its also for learning :slight_smile: