Giter VIP home page Giter VIP logo

arduino-midi-footswitch's Introduction

Arduino MIDI Footswitch

USB MIDI Pedal built with Arduino.

Disclaimer:
Please note, I'm not a C developer, so if the code looks ugly/poorly optimized you know why.
Everything I made was possible thanks to many info on the web, documentation and trial and error.
I'm not planning to actively support this project, I just thought it could be useful to have a small guide on how I made this, since I didn't find anything really straightforward at that point of time.
Hope this could come in handy for someone.

Update November 2019:
I've refactored the code to add a new "settings layer", read the Usage section for more info.

Update December 2021:
Changed pin numbers, also added a panel mount USB. Apparently, the Pro Micro USB is quite fragile and mine came off, so I bought another but this time I added a USB panel connector to relieve the stress off the Pro Micro plug. I highly suggest to do so.

Sections:

  1. Materials
  2. Hardware setup
  3. Software setup
  4. Rename the device
  5. Usage

Materials:

Hardware setup:

Going straight to the point, this footswitch will have:

  • 5 push buttons
  • 5 leds (one for each button), each one with a 10 KΩ 1/2W resistor
  • 1 Switch on the back, to select 3 different button "Layers" (like what the "Shift" key on your PC keyboard does, more or less)

Here is how I wired everything up on my SparkFun Pro Micro (click to open the larger image), if you use something different just remember to adjust pin numbers in the code later. (Black is GND, all the other colors are Data pins)

Arduino MIDI Footswitch Wiring

First I soldered everything in place, I used a small breadboard and some male plugs just to make everything cleaner and detachable, but you can solder directly on the SparkFun if you want to.

Soldered SparkFun

Then I put everything in an Aluminium Box with some holes for Buttons, LEDs, the switch, and the USB port.

Aluminium Box

Be sure to mask the bottom of the box (if made with metal) to avoid potential shorts, I used some electrical tape.

Aluminium Box

Connect some wires, put the SparkFun into the enclosure, and you are done with the hardware part!

Wires Wires Wires Aluminium Box with buttons

Software setup:

For the software part I'm assuming you already have Arduino IDE installed (mine is version 1.8.19).
In the Arduino IDE go to Sketch > Include Library > Manage Libraries.
Here search for the MIDIUSB library from Arduino, and install the latest version.

Only if you are using a SparkFun Pro Micro as I do
you will have to install the board in your Arduino IDE, to do so, follow this link and follow the instructions under "Installing the Arduino Addon" https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/installing-windows#windows_boardaddon

Ok, now we are ready to upload your code, finally.
Open the variables.h file, and if you made changes on pin wiring, be sure to edit the button_pins, led_pins or switch_pins variables according to your wiring.
Plug the USB cable from your Arduino/SparkFun to your PC, under Tools select the proper board and, if needed, select the proper CPU (SparkFun Pro Micro comes in 2 versions, 8MHz and 16Mhz, flashing the wrong one will cause the board to "soft brick", and you will need to reset it manually, learned this the hard way).
Now select the proper port and we can upload the code!

If everything is correct, it should be working. When you push a button the relative led should light up. To test the MIDI messages I used a lightweight free software called MIDI Tools, or you can directly use your DAW.

Arduino Footswitch

Rename the device:

This is an optional step. Normally, when you plug your footswitch, it will appear as "SparkFun Pro Micro" (or the name of the board you are using), so I decided to rename it. It's a very simple and fast step.

Follow the instructions created by nebhead at this link: https://gist.github.com/nebhead/c92da8f1a8b476f7c36c032a0ac2592a

I'll leave my own board file inside the other/ folder in this repo as an example.
In my case I named my folder footswitch and the device name is MIDI Footswitch.

After doing everything, restart your Arduino IDE and under Tools > Boards you should find a new "subcategory" with your newly created board inside.

Usage:

The MIDI footswitch changes his operational mode based on which position the rear switch is on.
So you have 2 "layers" of MIDI commands you can send, 5 on one layer and 5 on the other.
The first layer (switch up) have 5 static commands that all act as push buttons.
The second layer have 5 commands which behaviour can be customized using the third layer.
The third layer, is only a "settings" layer, pressing a button on this layer will turn on or off it's LED, changing the button behaviour.
LED OFF = the button acts as push button
LED ON = the button acts as Switch button

Useful links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.