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.
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.
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.
Saturday, July 30, 2016
A Mira control surface patch with high resolution MIDI support.
The MIDI mapping is as follows:
• Keyboard: MIDI notes 24 - 53
• Buttons: MIDI notes 60 - 72
• Pitchbend slider: 14-bit pitchbend
• Modulation slider: 7-bit CC #1
• Dials: 7-bit CC #2 - 3
• Toggles: 7-bit CC #4 -15
• Touch X and Y: 7-bit CC#16 - 17 (paired with CC#48 - 49 in 14-bit high res mode)
• Multislider with 8 sliders: 7-bit CC#18 - 25 (paired with CC#50 - 57 in 14-bit high res mode)
Download here: http://milkcrate.com.au/_other/downloads/max_patches/little-scale.Mira.MIDI.Surface.maxpat