Control Surface main
MIDI Control Surface library for Arduino


This is an example that demonstrates the use a Transposer to transpose the note events sent out by NoteButtons.

AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Teensy 3.x, ESP32, ESP8266


The internal pull-up resistor for the buttons will be enabled automatically.



Route the Arduino MIDI port into a synth to play the notes.

Written by PieterP, 2019-10-26

#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
// Instantiate a Transposer that can transpose from one octave down to one
// octave up
Transposer<-12, +12> transposer;
// Instantiate a Selector to change the transposition
{10, 11},
// Instantiate an array of NoteButton objects
{transposer, 2, MIDI_Notes::C(4)}, {transposer, 3, MIDI_Notes::D(4)},
{transposer, 4, MIDI_Notes::E(4)}, {transposer, 5, MIDI_Notes::F_(4)},
{transposer, 6, MIDI_Notes::G(4)}, {transposer, 7, MIDI_Notes::A(4)},
{transposer, 8, MIDI_Notes::B(4)}, {transposer, 9, MIDI_Notes::C(5)},
void setup() {
Control_Surface.begin(); // Initialize Control Surface
void loop() {
Control_Surface.loop(); // Update the Control Surface
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.
@ Clamp
When the maximum (minimum) setting is reached, clamp to the maximum (minimum) setting.
static constexpr uint8_t getNumberOfBanks()
Get the number of banks.
Definition: Bank.hpp:119
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).
Class for transposing the address of NoteButton and other MIDI elements.
Definition: Transposer.hpp:11
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
constexpr Note F_
F (Fa)
Definition: Notes.hpp:45
constexpr Note G
G (Sol)
Definition: Notes.hpp:47
constexpr Note E
E (Mi)
Definition: Notes.hpp:44
constexpr Note B
B (Si)
Definition: Notes.hpp:51
constexpr Note A
A (La)
Definition: Notes.hpp:49
constexpr Note C
C (Do)
Definition: Notes.hpp:40
constexpr Note D
D (Re)
Definition: Notes.hpp:42