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, Arduino.cc and Arduino.org. Both make their own version of the UNO. The version produced by Adafruit for Arduino.cc is considered to be the official version. The Arduino.org 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

Breadboard (63 pin width)

MIDI Jack

2 x 220 Ohm Resistors

Jumper Wires

MIDI Cable

Build It!

Watch this video for a step by step guide.

29 comments:

  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 ^^

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

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

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

      Delete
    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.

      Delete
    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.

      Delete
  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!

    ReplyDelete
    Replies
    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.

      Delete
  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.

    ReplyDelete
    Replies
    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.

      Delete
  5. This comment has been removed by the author.

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

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

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

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

      Delete
  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

    ReplyDelete
  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

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

      Delete
    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?

      Delete
  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

    ReplyDelete
  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,};

    ReplyDelete
  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?


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

    ReplyDelete
  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!

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

    ReplyDelete
  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

    ReplyDelete
  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.

    ReplyDelete
  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() {
    MIDI.begin();
    Serial.begin(115200);
    }

    Then set up hairless MIDI accordingly. Hope this helps.

    ReplyDelete