denalena / midi-footswitch-converter

Arduino MIDI Footswitch Converter project
GNU General Public License v3.0
0 stars 0 forks source link
arduino footswitch midi

MIDI Footswitch Converter

Photo of a prototype enclosed and in use Photo of a prototype enclosed with the top of the enclosure removed

Description

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.

Features

See the section Configuration for all supported settings.

Building it

Hardware needed

Wiring

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.

Photo of a prototype enclosure 3D printed and wired

Enclosure

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)

Configuration

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

License

This document, the photos and the source code is licensed under the GPL v3. The STL files are licensed under CC BY 4.0.