teensy midi controller

Eight DIY controlling Ableton Live


This project uses standard MIDI messages to communicate between a Teensy microcontroller and a computer, taking sensory information from the physical world and mapping it to processes and events on a computer. It can also be used to send messages from the computer to control things in the physical world, like LEDs, small motors, and relays.

Buttons, dials, and sliders are great and commonly used sensors for interacting with computers, but you can also use photocells that measure light, force sensors (FSRs) that measure pressure, conductive thread that measures capacitance or touch — there are so many different ways to measure and sense the world.

While MIDI is commonly used in musical instruments, it is a standard communication protocol that can also be used for interactive installations, live video performances, and kinetic sculptures. MIDI messages can be mapped to a broad range of software — Max/MSP, Ableton, Reaper, Mad Mapper, Processing — any program with MIDI input/output.

If this is your first time working with electronics and microcontrollers, start small.


Image result for midi logo
cool logo, MIDI!

(Musical Instrument Digital Interface) is a protocol developed in the early 1980’s as a way to connect music synthesizers. MIDI is fast and reliable and works with a lot of different software programs and hardware devices. While MIDI is lower resolution compared to serial communication, it helps us to get everything talking quickly and provides enough flexibility for most projects.

We are using Teensy microcontrollers instead of Arduino or other microcontrollers because they can be easily configured as class-compliant MIDI devices. When you plug it in, your computer automatically recognizes the Teensy as a midi device, and it can immediately be mapped to whatever program you are working with.


The Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via USB.

Teensy LC

I’ll be giving you some code to upload to the Teensy that will enable you to use it as a class compliant MIDI controller. Without changing the code, the Teensy LC will be able to accept 6 analog inputs, 12 digital inputs, and send 5 digital outputs. You can modify the code to accept up to 10 analog inputs, 23 digital inputs or outputs, and/or 9 touch/capacitance inputs — allowing you to alter/expand the code to suit your specific ideas.


To get started you will need some free software…

  • First, download and install the latest Arduino IDE (Integrated Development Environment) and install it by unzipping the downloaded zip file and dragging the Arduino program into your applications folder.
  • Make sure you install the Arduino IDE where your application live. Do not install it in your downloads folder.
  • Run the Arduino program! It is important that you run the program once before installing the Teensyduino library below.
  • Next, download the Teensyduino program and follow the installation instructions. Teensyduino is an add-on that will allow us to use the Arduino software with the Teensy microcontroller.
  • Last, download the project code and max patch here:
    • Download as a Bundle (Arduino sketch + MIDIMAX Max patch)
    • Download just the Arduino sketch

connecting sensors

(note that clicking on an image with open a larger version of the image in a new tab, easier to see!)

First, set up your power (VCC) and ground (Gnd) buses on your breadboard. When you connect the microcontroller to a computer, the board is powered via the usb cable. Also remember to use wires to connect the buses on either side of the breadboard so that you have power and ground running up and down both sides.

If your Teensy already has header pins soldered to the board, press it (carefully!) into the end of the breadboard. Make sure the usb port is facing out as in the picture above.

note the locations of the different pin types on the Teensy. Many pins have multiple functions, that can be specified in the code. For this course, we will focus on four different pin modes — digital, analog, touch, and pwm. Digital pins can either be inputs or outputs which can be specified in the code.

I have already uploaded some starter code to your microcontrollers. The starter code allows for a variety of inputs and outputs, but you can always change the code to add, subtract, or change pin allocations. The starter code pin definitions are as follows…

Here is a snippet from the code:

int const numDigPins = 10; // number of digital pins to send note values

int currentDig[numDigPins];

int digitalpin[] = {
  0,1,2,3,4,5,6,7,8,9 // which digital pins to use for sending note values

int digitalpitch[] = {
  40,41,42,43,44,45,46,47,48,49}; // midi note values corresponding to the digital pins

The code above says that there are 10 digital input pins defined. They are pins 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each pin corresponds to a MIDI note value that you can define as any number, but the starter code defaults to MIDI notes 40 through 49. So, pin 0 sends the MIDI note 40 (E2), and pin 6 sends the MIDI note 46 (Bb2).

digital inputs

Digital inputs send a binary signal to the computer, which we can think of as ON or OFF. Digital Inputs are good for triggering events (like a sound or video file) or playing a key (like on a keyboard) or changing the state of something.  Here we will connect a pushbutton and a switch, the most common types of digital inputs.

This picture above shows how to a momentary button or a switch (both digital inputs, same wiring). There is a detailed page on connecting a digital input (in this case a pushbutton) a little bit down this page on the Teensy site. The button and switch pictured above are made for breadboards, but buttons and switches come in all kinds of shapes and forms — the connection method remains the same!

In the image above, we see one leg of the button or switch is connected to power and the second leg is connected to ground through a 10K resistor (note that the switch has three legs, but for the most basic application we’ll only use two of them, leaving out one of the outer legs). The third wire connects the button/switch to an open digital input on your Teensy. In this case, the button is connected to D1 and the switch is connected to D2. When you press the button or flip the switch, the teensy will send a MIDI note to the computer.

analog inputs

Unlike Digital Inputs which only transmit two values (On and Off, or High and Low), Analog Inputs are continuous sensors that send a range of values. Analog inputs are great for variable control of parameters like speed, volume, or saturation.  The picture below shows how to connect a potentiometer and a photocell, typical Analog Inputs. There are a ton of different types of analog inputs. Some of the more complicated sensors are difficult to connect and use over MIDI, but the majority of analog sensors will work. For more detail, see the Analog Input tutorial on the Teensy website (or search for any of the million arduino resources on the topic).

The potentiometer doesn’t need an additional resistor, just connect one outer leg to power and the other to ground. The middle leg connects to an Analog Input  Pin, in this case A3.

The photocell does require a 10K resistor, which connects one of the legs to ground. The other leg is connected to the power bus and the leg with the resistor is also connected to an Analog Input Pin, in this case A4.

NOTE: any pins that are defined as Analog Inputs but are unused on the board should be connected to ground as seen in the picture above. If you leave analog input pins unconnected they will produce noise and if you try to map them to parameters in Ableton or other programs that have an automap feature, it will drive you crazy because the program will read the noise as you moving the control.

digital outputs

Connect the Anode (+) or longer leg of the LED to one of your digital output pins — in this case D13.

Connect the shorter, or cathode, leg to ground through a 220Ω resistor (red red brown gold).

If you play the MIDI note associated with pin D13, the pin is turned on, or set to HIGH, and will send 3.3v through the LED and the resistor, completing the circuit to ground. Your LED should turn on!

You can use a similar setup to drive a small motor. Connect one leg of the motor (it really doesn’t matter which leg in this case) to power (red) and the other leg to ground through a 10K resistor. You won’t be able to control the speed of the motor, but you’ll be able to turn it on and off from your computer by sending a MIDI note.

capacitance sensors

Capacitance Sensing with the Teensy is really simple and could be used with any kind of conductive material (thread, nails, copper wire, even bananas, and other non typical materials).

You need to set the pins you are using to TOUCH pins in the Arduino code, but then you can just connect any conductive material to the pin. When touched the pin will read as HIGH or ON and when you let go the pin will return to it’s LOW or OFF state. Great for making touch keyboards with non standard materials. The picture above is using A2, A3, & A4 as TOUCH pins instead of Analog Input pins. The little circles are supposed to represent nails or any other conductive metal object.