Control Surface master
MIDI Control Surface library for Arduino


Many bankable potentiometers and buttons. Bank selector displays bank setting using LEDs.
If any of the buttons is pressed, the LED on pin 22 is turned on.

#include <AH/STL/algorithm> // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(16);
// 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.
{21, 20}, // button pins
{46, 48, 50, 52}, // LED pins
using namespace MIDI_CC;
Bankable::CCPotentiometer potentiometers[] {
Bankable::NoteButton muteButtons[] {
{bank, 13, 0x14},
{bank, 12, 0x15},
{bank, 11, 0x16},
{bank, 10, 0x17},
{bank, 9, 0x18},
{bank, 8, 0x19},
{bank, 7, 0x1A},
{bank, 6, 0x1B},
{bank, 5, 0x1C},
{bank, 4, 0x1D},
{bank, 3, 0x1E},
{bank, 2, 0x1F},
{bank, 14, 0x20},
{bank, 15, 0x21},
{bank, 16, 0x22},
{bank, 17, 0x23},
{bank, 18, {0x33, CHANNEL_2}},
{bank, 19, {0x34, CHANNEL_2}},
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);
constexpr PinMode_t OUTPUT
Change the offset of the channel number of the element.
Definition: BankConfig.hpp:21
constexpr Channel CHANNEL_2
Definition: Channel.hpp:119
constexpr Channel CHANNEL_1
Definition: Channel.hpp:118
constexpr Channel CHANNEL_11
Definition: Channel.hpp:128
constexpr Channel CHANNEL_10
Definition: Channel.hpp:127
constexpr Channel CHANNEL_12
Definition: Channel.hpp:129
constexpr Channel CHANNEL_6
Definition: Channel.hpp:123
constexpr Channel CHANNEL_9
Definition: Channel.hpp:126
constexpr Channel CHANNEL_3
Definition: Channel.hpp:120
constexpr Channel CHANNEL_4
Definition: Channel.hpp:121
constexpr Channel CHANNEL_5
Definition: Channel.hpp:122
constexpr Channel CHANNEL_7
Definition: Channel.hpp:124
constexpr Channel CHANNEL_8
Definition: Channel.hpp:125
The main header file that includes all Control-Surface header files.
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
A class that groups Bankable MIDI Output Elements and Bankable MIDI Input Elements,...
Definition: Bank.hpp:91
A class of MIDIOutputElements that read the analog input from a potentiometer or fader,...
A class of MIDIOutputElements that read the input of a momentary push button or switch,...
void begin()
Initialize the Control_Surface.
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Selector with two buttons (one to increment, one to decrement). This version displays the setting usi...
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Names and values for all MIDI Control Change Controller Numbers.
constexpr uint8_t Sound_Controller_4
constexpr uint8_t Sound_Controller_3
constexpr uint8_t Sound_Controller_5
constexpr uint8_t Effects_2
constexpr uint8_t Effects_4
constexpr uint8_t Effect_Control_2
constexpr uint8_t Effects_1
constexpr uint8_t Channel_Volume
constexpr uint8_t Effects_3
constexpr uint8_t Sound_Controller_6
constexpr uint8_t Effect_Control_1