The goal of this project is to build a device that converts a simple analog on/off signal to a MIDI message. A simple footswitch or sustain pedal can be plugged into it and trigger the MIDI message over USB. I deliberately kept it quite simple to keep the source code hackable for Arduino beginners. For a similar but more advanced project, see the spiritual successor https://github.com/ledeniz/arduino-multi-switch
This code makes use of the Arduino library MIDIUSB.
- Acts as a native USB MIDI device
- Configurable MIDI channel, CC number and on/off values
- Note mode available: send a MIDI Note On/Off message (with or without CC)
- Toggle Switch mode
- Invert setting
- To switch pedal polarity
See the section Configuration for all supported settings.
- 1x arduino board with native USB port functionality (Zero, Due, 101, Micro, Leonardo)
- (I used a Sparkfun Pro Micro clone) (aliexpress)
- 1x mono or stereo 1/4inch input jack
- 1x simple footswitch or sustain pedal
Connect sleeve to ground and the tip to a pin with digital input capability. Be aware to not use a shunt contact if one is present on your jack.
STLs / Printables / Thingiverse
Remixed from “Enclosure for DIY Ambilight with Arduino Pro Micro controller” by Florian J. aka ShreddedABS: https://www.thingiverse.com/thing:4660540
Currently this is just a rough prototype, but it works ;) (I'm currently trying to learn CAD; I may update the models in in the future)
The device configuration is hard-coded. At the top of the sketch, you can find this configuration block:
//////// Configuration section
// CC mode: `MODE = MODE_CC`
// Note mode: `MODE = MODE_NOTE`
// Both: `MODE = MODE_CC | NOTE_NOTE`
const unsigned short MODE = MODE_NOTE;
// Act as a momentary switch (false) or toggle switch (true)
const bool TOGGLE = false;
// Inverts output values
const bool INVERT = false;
// MIDI channel 1-16, zero based
const byte MIDI_CHANNEL = 0;
// MIDI CC number. 4 = Foot Controller; 64 = Sustain Pedal
// https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2
const byte MIDI_CC = 64;
// MIDI value for state 'off' (0-127)
const byte MIDI_CC_MIN = 0;
// MIDI value for state 'on' (0-127)
const byte MIDI_CC_MAX = 127;
// MIDI note pitch value (0-127; 48 = middle C)
const byte MIDI_NOTE = 48;
// MIDI note velocity value (64 = normal, 127 = fastest)
const byte MIDI_NOTE_VELOCITY = 100;
// Pin number the jack tip is connected to
const int INPUT_PIN = 3;
// Threshold for when to allow the next trigger, in milliseconds
const int DEBOUNCE_MS = 30;
//////// END of Configuration section
This document, the photos and the source code is licensed under the GPL v3. The STL files are licensed under CC BY 4.0.