Thursday, 17 March 2016

Arduino MIDI Controller: Potentiometers

Take Control

In this installment of the MIDI for the Arduino series, we will apply the knowledge we have gained from previous chapters and begin the construction of a MIDI controller. This lesson deals specifically with potentiometers. But have no fear, we will cover buttons in the next installment.

Before You Start

This tutorial will ONLY work with the Arduino UNO. (Please don't ask if it will work on other Arduino models.) I am using some direct port manipulation in the code that is currently specific to the UNO. I'll let you know if this changes in the future.

The potentiometers I am using in the video are ALPS RK09L12D0A1W. Other types will work but they may not fit in your breadboard as nicely. You can simply solder some wires to them to make them work. Slide pots (faders) will also work if that's what you're into.

If you are planning to make a permanent version of this circuit, think about how you will mount the potentiometers and the size of knobs you will use before you buy your pots.

Buying An Arduino

As you may have heard, Arduino LLC (the company that created the brand) had a falling out with the manufacturing company that produced the original boards. There are now two entities, and Both make their own version of the UNO. The version produced by Adafruit for is considered to be the official version. The board should also work (although the Arduino IDE may complain a bit when you plug it in).

The Software

To make things simple, I have created a plug and play program that will allow you to customize your controller. All you need to do is tell the software the number of controls you will be using and how these controls should behave and the software will take care of the details. The video explains how to configure the software for your project.

Download the software HERE

Part List (With Amazon links)

Here are the parts you will need to complete this tutorial:

Arduino UNO or Arduino UNO (Official Adafruit Version)

6 x 10K Potentiometers (Linear taper) - Inexpensive
or model used in video (RK09L1140A66)

Breadboard (63 pin width)


2 x 220 Ohm Resistors

Jumper Wires

MIDI Cable

Build It!

Watch this video for a step by step guide.


  1. Hello, I would like to make a MIDI controller with an arduino uno, but i ask me how connect the MIDI jack to my computer, it's a laptop so i haven't MIDI port above it, i know it's above PC for keyboard and mouse but how connect to a laptop ?
    This video was very good and very well explain, good job ;)
    PS: sory for my bad english, i'm french ^^

    1. You can go to your local tech/computer store, or go online and purchase a "midi to USB" cable.

  2. can this progamme be modified to work with a arduino mega 2560

    1. Yes, just make sure you tell the program they type of board, and edit the pins accordingly.

    2. Hi Thomas. Yes it could be modified. It has some direct port manipulation routines that are custom to to the UNO that would have to be re-written for other boards though.

    3. hey Psykotek876, how do you do that? i am sufferieng man! help. i need to recode for 16 potentiometer with arduino mega 2560 and this is giving me problems. help.

  3. Another nice build Mr. NoteVolts! I am gearing up for this. I also am curious to the code which makes this only work on the Uno...bcuz of course im going to try it on these Mini-pros i have over here heheh, so if it works BOOM! I'll post what ever happens. So glad you have the energy so I can learn some more stuff!! Thx Dave!

    1. Hi Ben. Thanks for the encoragement! The reason that this code is currently for the UNO only is due to the direct port manipulation routine I am using to speed up the read times. This would have to be changed to make it work on different Arduino models.

  4. Nice tutorial, I think that 10k pots is only optimum when one pot is used, and is the recommended optimum value for arduino input ports (though it works with much higher values it is a matter of speed of conversion to use near to 10k values) but:
    When more than one pot is used, there is going to be less resistance between the gnd and vcc pins of each pot, resulting in equivalent use 1.5kohm pots !
    And while it will still work ; it will just make you source more current from the arduino and might be dangerous for the board. To solve that problem, you need to increase the resistance value of the pot according to the number of pots you have. As an example if you plan to use 6 pots, anything between 50k and 100k will do and will results in less current consumption.
    I think this especially matters if you get the current from the arduino directly and you plan to use it for other devices as well and if you plan to use a battery power source.

    1. Hi FF. This is actually incorrect. The ATmega328P chip on the arduino Uno only has one ADC input. The six analog inputs on the board a read one at a time through a multiplexer so only one pot is active at any given time. Even then, the ADC actually draws very little current.

      According to the spec sheet for the ATmega -"The ADC is optimized for analog signals with an output impedance of approximately 10k or less.".

      The ADC works by charging a capacitor through the resistance of the pot. Adding a higher value pot in the range of 100k will slow down this charging time and could result in less accurate readings.

  5. This comment has been removed by the author.

  6. can i make this with "Arduino Mega" using this programming code ?

    1. i am using a mega and the buttons work but am having an issue with the pots,,,

  7. I am also looking for Mega2560 program . Please if anyone has the solution , that I would be of great help.

    1. sorry for my english, i'm french!

  8. hi dave,,
    i got the pot to work but it sends a cc message in 1 line only then if i continue to turn the pot it sends notes,,,using mega bd,,,thx

  9. hi dave,,in regards to the pots sending out notes ,do you think its a mega bd issue,,i can simply get a uno bd if you think that is the problem.thx

    1. Hi Terry. This code on;y works with the Arduino Uno. See the section under "Before you Start" for details.

    2. I try it first with my arduino uno adeept the pots doesn't work then with arduino mega it does the same can you help us?

  10. hey there i am trying to run this code using 16 pots connected through analogue mux and it just will not compile i get this from the dude ..MIDI was not declared in this scope on the line that begins,, if (potmessage != 255.. in the void muxpots section the create_mdi_instance lines not working either so i tried to comment it out i am noob to this any help much appreciated

  11. Arduino: 1.6.13 (Windows 10), Board: "Arduino/Genuino Uno" MIDI_Controller_v1-2:54: error: 'PO1' was not declared in this scope Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5,}; ^ MIDI_Controller_v1-2:54: error: 'PO2' was not declared in this scope Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5,}; ^ MIDI_Controller_v1-2:54: error: 'PO3' was not declared in this scope Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5,}; ^ MIDI_Controller_v1-2:54: error: 'PO4' was not declared in this scope Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5,}; ^ MIDI_Controller_v1-2:54: error: 'PO5' was not declared in this scope Pot *POTS[] {&PO1, &PO2, &PO3, &PO4, &PO5,};

  12. hi guys,

    i was wondering if i would be able to get away without making the midi jack circuit but just connecting the uno with the normal usb 2 port.

    what do you think?

    1. Hay varios programas para lograr dicha conversión, y tendrías que modificar el código en el Voip setup serialmidi

  13. Does it work with the midi mapping of VoiceMeeter Banana?

  14. Hello, nice work!! Thank you for sharing. I need to dig into the code but quick question --- does the current implementation support sending SysEx messages and not CC? Thanks!

  15. This doesn't only just work with the UNO. I got it working with the Pro Mini.

  16. Hi - Thanx for a very nice job ;-)

    I would like to use your project for a box to use with 1 to 6 expression pedals through a stereo jack input. I have tried it out with one expression pedal so i suppose it will work with 6 as well when you do the correct setup in the software - is this correct ?

    Anyway when i dont attach an expression pedal, then the box put´s random midi messages. Is there a way to use maybe a resistor on the analoge inputs in order to keep the unused inputs "silent" when no expression pedal is connected ?

    I would also like to make 4 other inputs for the digital inputs (for note, sustain and other simple midi commands) using momentary switches - i belive there would the same problem if no switch is connected - is this correct ?

    Last i would like to use a midi input which would be merged to the midi out, in order to insert the box and not needing an extra midi input - can i use your midi input hard and softwaere soloution and add the code to the potentiometer software ?

    nice regards

    Henning Flintholm

  17. Hello David, I am a young man who loves electronics, I am from Peru, I am very interested in your video, make a video with your code in my way to control a software called VIRTUALDJ 7, and modify some parts to make the serial communication Without midi cable, only use the usb cable of the own arduino ONE.
    Of course the video does not do it in a professional way but I did everything I could to share this that is so beautiful.

    But I have a doubt, when loading the code everything is fine everything works great, but the moment I disconnect the arduino and reconnect, the code is deleted, it is as if everything is reset and I have to reload the code; That I have to do so that the code is permanently recorded in the arduino and is not erased at the moment of disconnecting it.
    thanks greetings.

  18. If anyone is wanting usb MIDI without the extra wiring (MIDI output/input) I had success with using hairless MIDI with loop MIDI.

    I modified my version of the script so hat the setup now reads

    void setup() {

    Then set up hairless MIDI accordingly. Hope this helps.

  19. hi
    where do you buy the knobs for your product.

    I am having an hard time in finding them

  20. im got error, help me :

    Arduino: 1.8.3 Hourly Build 2017/03/23 09:33 (Windows 7), Board: "Arduino/Genuino Uno"

    E:\Study Room\Programming\Tutorials Library\Video Tutorials\arduino\MIDI Controller\MIDI FILE\MIDI_Controller_v1-2\MIDI_Controller_v1-2.ino:1:18: fatal error: MIDI.h: No such file or directory



    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

  21. Hola David, realize más pruebas con tu código y modifique la salida serial para hacer la conexión MIDI dé manera virtual utilizando un programa de COMPUTADORA, y luego modifique su firmware para convertirlo en dispositivo HID , el uso que le estoy dando es hacer un controlador DJ , pero quiero una ayuda de tu parte porque quiero añadirle 2 decodificadores rotatorios (encoder) pero no sé cómo añadirle el código ,me podrías ayudar a agregarle encoders a tu código. Sí es tan amable de responder a mi petición.

  22. This comment has been removed by the author.

  23. hello is there a way to get this with a midi input?
    So I can connect this from my pc to my synth using the arduino as a CC controller?