100% found this document useful (1 vote)
195 views

Arduino MIDI Volume-Expression

This document describes a project to send MIDI control change (CC) messages from an Arduino Pro Micro to control volume and expression using a volume pedal. The project uses potentiometers in volume pedals connected to analog pins on the Arduino to send CC messages over USB MIDI. The Arduino code samples the potentiometer and sends updated CC values when the reading changes. Compatible volume pedals include those with separate input and output jacks, or pedals like the Roland EV-5 with a TRS connector.

Uploaded by

herintzu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
195 views

Arduino MIDI Volume-Expression

This document describes a project to send MIDI control change (CC) messages from an Arduino Pro Micro to control volume and expression using a volume pedal. The project uses potentiometers in volume pedals connected to analog pins on the Arduino to send CC messages over USB MIDI. The Arduino code samples the potentiometer and sends updated CC values when the reading changes. Compatible volume pedals include those with separate input and output jacks, or pedals like the Roland EV-5 with a TRS connector.

Uploaded by

herintzu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MIDI

Volume and Expression


Control using an Arduino Pro Micro
By Simon Girouard

Introduction

This is a simple MIDI project that anyone can do easily. The goal is to have a very basic yet functional
way of sending MIDI Control Change (CC) messages to host devices such as Mod Devices Mod Duo, DuoX
and Mod Dwarf.

This project makes use of the USB port to carry the MIDI events but can be adapted to regular 5 pins DIN
if required.

To achieve this, the Arduino Pro Micro is used. This microcontroller has already a built in USB compliant
port that is viewed as a normal USB device by the hosts computer or device.

What’s required?
Materials:

- An Arduino Pro Micro (https://www.amazon.com/Sensors-ATmega32U4-Replace-ATmega328-


Arduino/dp/B08D11Q94H/ref=sr_1_37)
- ¼” Stereo female jack(s) (Amazon.com: Switchcraft Type 12B (Pack of 2) Stereo 3-Conductor
Input Jack, 1/4", Double Open Circuit, Made in USA : Electronics)
- Small pieces of wire

Tools:

- Soldering iron and electronic solder


- Plyers, cutters, etc …

The final assembled project can be fitted into a small plastic or metal project box and the Arduino board
held inside with a dab of glue from a glue gun. Any other arrangement is also fine, and I will leave that
part to your discretion.

Simon Girouard
Jan. 2022 page 1
Compatible volume pedals

This project uses potentiometers (variable resistor) to determine the value that will be eventually sent
to the host.

Basically, any analog volume pedals with “Input” and “Output” jacks and no electronic parts aside from a
potentiometer will work. This is the case for some Ernie Ball volume pedals.

This type of pedal will require a “Y” adapter in order to work with this project. The schematic and
instructions to build such an adapter are available at the end of this document in the appendix.

Other volume pedals such as the Roland EV-5 are already designed to be used with hosts equipped with
an expression connector. As seen in the diagram below, the cable out of the pedal has a “TRS”
connector instead of the “Input/Output” pair seen in fully analog volume pedals mentioned above.

Our project will be wired to match this “TRS” configuration.

Note: The Roland EV-5 and other pedals have a 2nd potentiometer on the side to limit the range.
Although not tested in this project, it should work in the same manner as it would if connected to any
other commercial device.

WARNING: If your volume pedal already has electronic circuitry and/or requires a 9v battery to operate,
it is NOT usable with this project and it may even be damaged if you attempt to do so.

Simon Girouard
Jan. 2022 page 2
Arduino connections

Only 3 pins from the Arduino are required to connect our ¼” TRS jack:

- Ground (in green)


- +5v (in red)
- Arduino analog input pin (in yellow)

It is possible to have up to 4 expression pedals with this project because there are 4 analog pins on this
Arduino. Slight changes to the code will be required if more than one expression pedal will be used.

Programming the Arduino

The Arduino IDE is used to edit the code and send the compiled version of that code to the Arduino.
Once you have downloaded the installer, install and launch the Arduino IDE (Integrated Development
Editor).

In a new “Sketch” (editor window), copy and paste the code below:

/*** Start of code ***/


/*
Simple USB MIDI CC Send for expression pedals.
This code was made for an Arduino Pro Micro but will work on any
Arduino with the ATmega32u4 microcontroller.

Potentiometer wiring:
- Right pole to Arduino GND pin.

Simon Girouard
Jan. 2022 page 3
- Left pole to Arduino VCC pin
- Center pole to Arduino analog input pin (Ex: A0)

For this version, MIDI Channel and CC number are hardcoded in the initialization command (see
"setup" function).

Created January 22nd, 2022


By Simon Girouard
*/
#include "MIDIUSB.h"

// Class "Expr" defines a MIDI control of type "Expression".


// It will send a CC message to a device using USB MIDI
// only when the position of the potentiometer changes.
class Expr {
int HWPin;
byte Channel;
byte CCIdx;
byte CCValue;
public:
void init(int _HWPin, byte _Channel, byte _CCIdx) {
HWPin = _HWPin;
Channel = _Channel;
CCIdx = _CCIdx;
CCValue = 0x00; // Default to "0" when initializing the object
}
void DoProcess() {
int NewVal = CCValue;
for (int i = 0; i < 3; i++) { // Take 3 samples of the analog input
int Val = (uint8_t) (map(analogRead(HWPin), 0, 1023, 0, 127)); // Translate the
analog pin's value from range 0 to 1023 into a MIDI range of 0 to 127.
//if ( abs(Val - NewVal) > 1 ) NewVal = Val; // Is there's a difference of one or
more than the threshold value?
if ( abs(Val - NewVal) > 1 ) NewVal = Val; // Is there's a difference of one or more
than the threshold value?
//delay(4); // Wait a bit before taking the next sample (Note: Remove comment if
there is jitter in the potentiometer readings).
}
if (CCValue != NewVal) { // Send MIDI CC only if value has changed
CCValue = NewVal;
midiEventPacket_t event = {0x0B, (byte)(0xB0 | Channel), CCIdx, CCValue}; //Note: The
"Byte" casting is there to resolve a "narrowing conversion" warning at compile time.
MidiUSB.sendMIDI(event); // Send to MIDI buffer.
MidiUSB.flush(); // Transmit buffer immediately.
}
};
};

//Declaration of objects of class "Expr".


Expr Expression1;
//Expr Expression2; /* Un-comment this line if you want a 2nd expression pedal */
//Expr Expression3; /* Un-comment this line if you want a 3rd expression pedal */
//Expr Expression4; /* Un-comment this line if you want a 4th expression pedal */

void setup() {
Expression1.init(A0, 0, 7); // Initialize the expression pedal (Arduino Analog Pin,
MIDI channel, CC Number)
//Expression2.init(A1, 0, 11); /* Un-comment this line if you want a 2nd expression pedal */
//Expression3.init(A2, 0, 13); /* Un-comment this line if you want a 3rd expression pedal */
//Expression4.init(A3, 0, 15); /* Un-comment this line if you want a 4th expression pedal */
}

void loop() {
Expression1.DoProcess(); // Process Expression Pedal 1
//Expression2.DoProcess(); /* Un-comment this line if you want a 2nd expression pedal */
//Expression3.DoProcess(); /* Un-comment this line if you want a 3rd expression pedal */
//Expression4.DoProcess(); /* Un-comment this line if you want a 4th expression pedal */
}

/**** End of code ****/

Simon Girouard
Jan. 2022 page 4
This code can be edited to allow for up to 4 expression pedals with each their own ¼” TRS jack.

To do so, remove the “//” (comment tag) at the beginning of the lines with the text “Un-comment this
line if you want…”

Ex:

Current line:

Comment tag removed for a 2nd expression pedal:

Other changes you may want to do is the CC message number and MIDI channel you want each
expression pedal to be configured with.

To change these values, edit the parameters of the “init” command for each of the pedal objects in the
code:

In the example above, “A0” corresponds to the first analog pin on the Arduino board where the signal
wire to the TRS jack is connected.

The second parameter is the MIDI channel (0 to 15) you want this pedal to use to send the CC.

The third parameter is the actual CC number (control identifier) of the control in your host device. In the
code above, the identifier “7” is the standard for a “Volume” control and “11” for an “Expression”
control.

Simon Girouard
Jan. 2022 page 5
Note: Upon powering the Arduino, the default value sent in a CC message is “0” (off) to prevent your
ears and/or speakers to be damaged. In the next version of this project, it may be possible to set a
default value so controls other than “Volume” would not have to be restricted by this.

Before compiling and uploading the code to the Arduino, you must tell the Arduino IDE which
microcontroller you are using. You will find the selection in “Tools-> Board: ….” and select the
appropriate board you re using. In the case of the Arduino Pro Micro, select “Arduino Micro”.

Then you must select the USB port onto which the Arduino is connected to your computer. This port
may not be the same from one computer to another so you may have to try other listed ports to find the
right one.

Simon Girouard
Jan. 2022 page 6
You can test the port by selecting “Get Board Info”. If there is no error and the model of the
microcontroller is displayed, you have the proper port. Else, try another port.

Once the code is edited to your liking, start the compilation and upload process to the Arduino by
clicking on the “Upload” button (circled in red):

When the upload is completed, the status bar will indicate “Done uploading”.

Simon Girouard
Jan. 2022 page 7
If there are errors, revise the code to make sure you did not change something other than removing
some “//” for additional expression pedals or modified the parameters in the “init” command of each
pedal objects.

Testing the pedal

To test that the pedal is working, unplug the Arduino USB cable from your computer and then connect it
to the device you want to control.

If all is well, the host’s control should react to the pedal being used.

The future of this project

Here are the additions and changes I will do to this project soon:

- Allow for a default value chosen by the user instead of defaulting to “0” at power up.
- Replace hardcoded values with a dynamic configuration Windows and/or Mac utility (instead of
compiling and uploading code to the Arduino every time you want to change pedal parameters).
- Introduction of “Stomps” (foot switches) that can be either “Momentary” or “Latch”.
- Introduction of PC messages (Program Change).
- Ability to send “Notes”.

Simon Girouard
Jan. 2022 page 8
Appendix
Normally, using an analog volume pedal with “Input” and “Output” jacks would require a modification of
the wiring in the pedal. This would make it useless for normal analog use.

The following “Y” adapter (Fig 2.) will allow you to use your volume pedal without any modifications.
Simply connect the two ¼” male plugs into their respective “Input” and “output” jacks on your pedal.

IMPORTANT: Make sure that the plug marked with “To volume pedal input” actually is plugged into
the “Input” jack of your volume pedal. Reversing these 2 plugs will cause the GND and +5V to short
and this may cause damage to the Arduino.

Simon Girouard
Jan. 2022 page 9

You might also like