Simple Midi Controller: Simple Knob / Slider

knobs

We’ve created a simple midi controller that utilizes a single button to send messages to a device through USB. A button can trigger effects, play notes, or toggle settings. But what if we want to change a value to anything from 0% to 100%, as can be done with a knob or a fader?

knobs

A knob is typically an easy to grip cap the user can turn to adjust a potentiometer. A potentiometer (pot for short) is essentially a resistor that we have cut in the center, and can adjust where the cut is with a slider or knob, changing how much of the resistor is left on each side. We can use this to create a variable voltage divider, using the variable voltage read by the Teensy and convert that into a value to send in our midi message.

Using a three lead potentiometer, if you connect only the first lead and the second, you can adjust the amount of resistance the pot creates (from 0% to 100% of it’s resistance rating), thus adjusting the current through the pot. If you connect the first and third leads to higher and lower voltages (5V and ground (0V)), the second lead will give you a value between the two depending on the value you set the pot to, creating a voltage divider.

Note that there are two position relationship types: linear taper and logarithmic taper. Log pots are typically used in audio amplifiers, as our perception of sound volume is logarithmic. For everything else, use linear taper.

You should not use a voltage divider to step down supply power, such as 12V to 5V to power an Arduino. Any current required by the powered device must pass through the voltage divider, which will heat up the voltage divider. Pot’s power ratings are typically pretty low, so avoid high current usages.

We’re going to use some kind of potentiometer for our expression pedals, as we will want to control an active effect by moving through values rather than just “on” and “off”. While I wait for the slide potentiometer I ordered to use for the final device, I’ll use a breadboard friendly pot to test my software on.

Hardware

The hardware required for this project is as follows:

  • 1 Teensy 3.1 with USB Connection
  • 1 Breadboard
  • 1 Potentiometer (I used a 50k ohm linear pot, but a lower value should work better)
  • 3 jumper wires

Breadboard Setup

The parts are assembled to the breadboard as per the diagram below. One side of the pot is connected to 5V, the other side to ground, and the center is connected to one of our analog pins (analog pin 5 in this case).

Single Knob Breadboard

We can set the pin to detect analog signals with the Teensy’s built in analog-to-digital converter.

Program

Make sure you set the board to your Teensy 3.1 board in the Tools menu. You also will want to change the Tools > USB Type to MIDI instead of Serial.

Enter the following sketch:

If your sketch verified smoothly, upload it to the Teensy 3.1. Your computer should now detect a Midi Controller Device. Try out your single “knob” midi controller in your program of choice!

2 Responses to “Simple Midi Controller: Simple Knob / Slider

Leave a Message!

Your email address will not be published. Required fields are marked *