Teensy MIDI Controller Code
- Categories Resource
I’m a big fan of the Teensy microcontroller family. They are small, cheap, have plenty of ins and outs, and you can turn them into USB MIDI devices really easily (or many other types of standard USB devices). The Teensy 3 and LC also have a bunch of “touch pins” built in, which means you can just attach any bit of metal to them and they’ll become capacitive touch sensors.
I would highly recommend them to anyone embarking on building a custom MIDI controller – Arduino gets all the headlines, but the Teensy is really much better for that kind of thing. If you are sticking to MIDI devices the LC version will do everything you need at a low cost.
However, it can be tricky to get started. I’ve managed to put together a piece of code which is relatively flexible and can be used for any number of combinations of buttons/knobs/touchpins/etc.
This code was made in the Arduino environment and should work with any of the Teensy boards. The only exception is the touch pins, which will only work on Teensy 3 or newer, as well as the LC.
The code has comments to show you where to input the number of pins you want to have each function, and which specific pin numbers to use for each function. For MIDI notes there are arrays where you can specify which notes to use. The different available functions in version 2.0 are:
- Analog inputs to send CC values
- Digital inputs to send note values
- Digital inputs to send CC values
- Touch pins to send note values (with constant velocity)
- Use MIDI output to control things attached to the pins (lights/motors/etc)
- Support for both usbMIDI and regular MIDI using din connectors
Still to do:
- Add ability to use Touch pins as CC (this is tricky…)
- Add pitch bend support
- Get this all up on github for better version control
You’ll have to set the serial port to MIDI – for more information read the page on the PJRC site.
Teensy MIDI Controller Code v1.0
Get in touch if you have any questions or if you run into any trouble.