Saturday, July 30, 2016

Simple MIDI Rotary Encoder with Teensy / Arduino

Overview
A rotary encoder uses digital encoding of pulses in either a clockwise or counter-clockwise direction to determine relative location. This particular rotary encoded includes a push button as part of the shaft. 

This example shows how to connect a single, simple rotary encoder, and use the output as a MIDI controller.



Hardware
This particular encoder has five pins. The group of three pins on one side is the encoder. The group of two pins on the other side is the


For the group of three encoder pins, connect the right hand pin to a digital pin on the Teensy. In this case, pin 2 has been chosen. Connect the left hand pin to a digital pin on the Teensy. In this case, pin 3 has been chosen. Connect the middle of the three pins to ground.

These particular pins have been selected because they support interrupts on the Teensy LC. Refer to the Teensy pinouts to see possible pins, labelled INT. Note that Teensy 3.1 and 3.2 support interrupts on all digital pins.

For the group of two button pins, connect one pin to a digital pin on the Teensy and the other pin to ground.





Software


Download here: http://milkcrate.com.au/_other/downloads/arduino/Teensy_Rotary_Encoder.ino

The code uses the encoder library, which is included with the Teensyduino install. The encoder is mapped to MIDI CC #1 channel 1, and is constrained to 0 - 127. The button is mapped to MIDI CC#2 channel 1.



Video

0 comments: