If you missed the downloads on the software page, be sure to download and install the Arduino IDE and the two Libraries before continuing to this step. Also download the Arduino sketch and Max patch, which includes the Arduino sketch referenced below and a Max/MSP patch for debugging (optional).
The open-source Arduino Software (IDE) makes it easy to write code and upload it to any Arduino compatible board. This video is an in-depth look at the Arduino IDE — it focuses on the Arduino Uno board but the concepts are the same for the Teensy boards.
Uploading your code to your microcontroller:
- Open the “pro_micro_2023.ino” file in the Arduino IDE.
- In the tools menu, select your board — if you are using the pro micro, select Arduino Leonardo
- After selecting your board, in the tools menu, select “MIDI” as your USB Type
- Click the “upload” button on the top left of the sketch toolbar… it’s the right pointing arrow.

set up
The starter code below is written with 5 digital inputs, 4 analog inputs, and 2 digital outputs, but you can change a few lines to the code to add, subtract, or change pin allocations. You can download the starter code here, or just paste the code below into an arduino sketch…
/**
*
* free sounds interface
*
* This code is part of a system developed as a learning tool for the
* new media + sound arts program at Emily Carr University. It is designed
* to be used with the Arduino Pro Micro, but will likely work with other
* microcontroller boards as well. Without changing the code, you can connect
* one button, one toggle, a potentiometer, an LDR (light sensor), and an LED.
* From these building blocks, you can create computer interfaces with different
* types and arrangements of sensors and/or actuators. more information:
*
* http://www.newmusicalinstruments.org
*
*
* At the core of this system is a wonderful Arduino library called
* "control surface", written by PieterP:
* https://github.com/tttapa/Control-Surface
*
*
* connections
* -----------
*
* printable wiring diagram:
* http://www.newmusicalinstruments.org/diagram
*
* Digital Inputs
* - pin 5: momentary push button (midi note C4 or 60)
* - pin 6: toggle switch (midi note D4 or 62)
* connect one leg to the pin and one leg to ground
*
* Analog Inputs
* - pin A0: potentiometer (CC 10)
* - pin A1: Light Dependant Resistor (CC 11)
*
* Digital Output
* - pin 9: LED output (midi note E4 or 64)
*
*
* behavior
* --------
*
* - When the button on pin 5 is pressed, a MIDI Note On message is sent for
* note C4 (midi note 60). When the button is released, a MIDI Note Off message is sent.
*
* - When toggle on pin 6 is switched, a MIDI Note On message is sent for note D4 (midi note 62).
* When the button is released, a MIDI Note Off message is sent.
*
* - When you turn the potentiometer connected to pin A0, continuous messages will be sent to CC 16
*
* - The light dependant resistor connected to pin A1 will send continous messages to CC 17
*
* - An LED connected to pin 9 turns on and off with note E4 (midi note 64)
*
* You can add additional buttons, toggles, potentionmeters, LEDs and other sensors/actuators to support your ideas.
* Take a look at the Control_Surface examples (File > Examples > Control Surface) for more complex components/connections (pwm, LCD screens, multiplexers, LED rings, etc)
*
*
*
*
*
*/
#include <Control_Surface.h> // Include the Control Surface library
USBMIDI_Interface midi; // Instantiate a MIDI over USB interface.
// Instantiate an array of NoteButton objects that send
// MIDI note events when a push button or toggle is pressed/released
NoteButton buttons[]{
{ 4, MIDI_Notes::C(4) }, // Push button on pin 4, “play” control
{ 5, MIDI_Notes::D(4) },
{ 6, MIDI_Notes::E(4) },
{ 7, MIDI_Notes::G(4) },
{ 8, MIDI_Notes::A(4) },
};
// Instantiate an array of CCPotentiometer objects that send
// MIDI CC messages when an analog sensor is changed (0-127)
CCPotentiometer potentiometers[]{
{ A0, 10 }, // Analog pin (A0) connected to potentiometer, midi controller number (10)
{ A1, 11 }, // {Analog pin (A1)connected to light dependant resistor (LDR), midi ontroller number (11)
{ A2, 12 },
{ A3, 13 },
};
// Instantiate an array of NoteLED objects that receive midi note events from the
// computer to turn LEDs on and off on the microcontroller
NoteLED leds[]{
{ 17, MIDI_Notes::C(5) }, // Pin of built-in LED, Note C5 on MIDI channel 1
{ 10, MIDI_Notes::D(5) }
};
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}
This code is has been created for the free sounds interface, and this pdf goes through the code and connections to build one of these controllers. You can also 3d print the case and laser cut the top. All of the files — code, fabrication files, and max patch — can be downloaded here.
The following pages break down the above code to help you understand what is happening in each section. The Control Surface Library is doing a lot of the heavy lifting in this sketch, and we are basically tasked with telling the arduino what inputs and outputs are connected to which pins.