Ordinary expression pedals are passive analog devices that receive electrical input from, for example a synth, attenuate the current via a potentiometer, and then return the signal to the instrument. I own several MIDI keyboards, a control surface, a hardware synthesizer and, although they all have 1/4" TS sustain sockets (2-wire on/off), none of them is equipped with a 1/4" TRS port (3-wire) to connect an expression pedal.
Nektar NX-P expression pedal. I got mine from a local store.
Teensy LC development board. This Low Cost device has class compliant USB MIDI capability and is compatible with Arduino. I got mine from a local store.
Micro-USB-type-B to USB-type-A cable.
Tools: soldering iron, solder wire, screwdriver, scissors.
Connect Teensy LC to the computer.
Install Teensyduino – a modified Arduino IDE with Teensy device support.
On Arch Linux
$ paru -S teensyduino
Open Arduino IDE software application and configure it.
Tools > Board: "Teensy LC"
Tools > USB Type: "MIDI"
Tools > Port: "/dev/hidraw4 MIDI (Teensy LC)"
Download the required .ZIP library packages (by Josh Nishikawa).
https://github.com/joshnishikawa/MIDIcontroller
https://github.com/joshnishikawa/Flicker (only needed to compile)
I used MIDIcontroller version 2.5.4. Features included: stable analog to MIDI conversion for potentiometers and other sensors.
In Arduino IDE, import the two libraries.
Sketch > Include Library > Add .ZIP Library...
In Arduino IDE, open the MIDIpot example sketch.
File > Examples > Examples from Custom Libraries > MIDIcontroller > MIDIpot
Modify the source code.
line 3: MIDI channel = 1, but can be any valid number from 1-16.
byte MIDIchannel = 1;
line 10: CC (Control Change) = 11 for expression, or CC = 1 for mod wheel, or something else.
MIDIpot myPot(potPin, 11, KILL);
Save sketch folder as ~/Arduino/ExpressionPedal
In Arduino IDE, open the MIDI_name sketch.
File > Examples > Built-in Examples > Teensy > USB_MIDI > MIDI_name
Modify name.c to set a custom USB device name.
#define MIDI_NAME {'N','X','-','P'}
#define MIDI_NAME_LEN 4
MIDI_NAME_LEN must be an integer corresponding to the number of characters used in the name, including spaces.
Save sketch folder as ~/Arduino/MIDI_name
Move ~/Arduino/MIDI_name/name.c to ~/Arduino/ExpressionPedal/name.c
Delete ~/Arduino/MIDI_name
In Arduino IDE, compile the code.
Sketch > Verify/Compile
This should build the program, then automatically upload it and reboot the board. There is no need to press the button on the board itself to enter Program Mode. (The physical pushbutton is provided to allow recovery from bad code.)
If more code changes are made, in Arduino IDE, compile again and then manually upload.
Sketch > Verify/Compile
Sketch > Upload
If all is OK, unplug Teensy LC.
Remove all screws from the bottom plate.
The cable is taped to the plate inside. Slowly and carefully start pulling the plate away from the enclosure. Peel off the tape to release the cable.
Cut the two black wires coming from the polarity switch as close to the switch as possible.
Cut the other black wire (bundled with white and red) close to the base insulation.
Strip the ends of all three black wires inside the pedal.
Get the soldering iron ready and tin the wire ends.
Insert the solid unpaired wire into the GND pin hole of Teensy.
Insert the dots-only paired wire into the 3V pin hole.
Insert the dots-and-stripes paired wire into pin hole 14 (analog A0).
Connect the USB cable and rock the pedal back and forth to test with software (I checked in Renoise). MIDI values should change gradually from 0-127. If the range is narrower, adjust the sensitivity pot on the pedal itself. If the range is inverted, the paired wires going to 3V and 14 are reversed.
If all is OK, solder the wires.
Use zip ties inside and outside the enclosure near the cable outlet to make "knots" to secure the USB cable.
Place the ground wire ring terminal over the original screw hole, reassemble the unit, and tighten all the screws.
The USB MIDI Expression Pedal is now ready to use with DAW software without any additional device drivers.