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 (RK09L1140A66)
Breadboard (63 pin width)
MIDI Jack
2 x 220 Ohm Resistors
Jumper Wires
MIDI Cable
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 ?
ReplyDeleteThis video was very good and very well explain, good job ;)
PS: sory for my bad english, i'm french ^^
You can go to your local tech/computer store, or go online and purchase a "midi to USB" cable.
Deleteor use hairless midi
Deletepuedes usar un software virtual ...virtual serial midi
Deletecan this progamme be modified to work with a arduino mega 2560
ReplyDeleteYes, just make sure you tell the program they type of board, and edit the pins accordingly.
DeleteHi 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.
Deletehey 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.
DeleteI have the same problem !
DeleteAny solution for the MEGA 2560? I need more analog imputs (multiplexer is not a solution for me, I want to use only a simple board). Somebody has the code (maybe modified) working in the MEGA 2560? Thanks.
DeleteArduino Pro Micro
Deletehttps://wiki.eprolabs.com/index.php?title=Arduino_Pro_Micro
He modificado en Controler.cpp
pinMode(15, OUTPUT); //antiguo pin2
pinMode(16, OUTPUT); //antiguo pin3
pinMode(14, OUTPUT); //antiguo pin4
if (numPins > 8) pinMode(8, OUTPUT); //antiguo pin5
y mas abajo...
void Button::muxUpdate()
{
byte temp = _muxpin;
temp = temp << 1; //antiguo 2
if (_numMuxPins > 8) PORTB = PORTB & B11100001; //antiguo PORTD & B11000011
else PORTB = PORTB & B11110001; //antiguo PORTD & B11100011
PORTB = PORTB | temp;
}
Y...
void Pot::muxUpdate()
{
byte temp = _muxpin;
temp = temp << 1;
if (_numMuxPins > 8) PORTB = PORTB & B11100001;
else PORTB = PORTB & B11110001;
//PORTB = PORTB & B11000011;
PORTB = PORTB | temp;
}
Parece que funciona.
Probaré para Mega 2560.
gzk187@hotmail.com
Hola...
DeletePara Arduino MEGA2560....
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
if (numPins > 8) pinMode(27, OUTPUT);
mas abajo...
void Button::muxUpdate()
{
byte temp = _muxpin;
temp = temp << 2;
if (_numMuxPins > 8) PORTA = PORTA & B11000011;
else PORTA = PORTA & B11100011;
PORTA = PORTA | temp;
}
Y...
void Pot::muxUpdate()
{
byte temp = _muxpin;
temp = temp << 2;
if (_numMuxPins > 8) PORTA = PORTA & B11000011;
else PORTA = PORTA & B11100011;
//PORTA = PORTA & B11000011;
PORTA = PORTA | temp;
}
Tambien parece funcionar.
gzk187@hotmail.com
He usado los arduinos con 2 multiplexores analogicos 74hc4067 conectando los pines S0, S1, S2, S3 en los pines modificados anteriormente en su mismo orden
Deletemicro:
S0 ---- pin2 ------> pin15
S1 ---- pin3 ------> pin16
S2 ---- pin4 ------> pin14
S3 ---- pin5 ------> pin8
mega2560:
S0 ---- pin2 ------> pin24
S1 ---- pin3 ------> pin26
S2 ---- pin4 ------> pin27
S3 ---- pin5 ------> pin28
gzk187@hotmail.com
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!
ReplyDeleteHi 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.
DeleteNice 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:
ReplyDeleteWhen 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.
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.
DeleteAccording 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.
He wasn't talking about the ADC :) He was saying all the pots are in Parallel and connected to the Arduino's 5V output, decreasing the total Parallel resistance of the circuit, which will put more load on the Arduino's voltage regulator. The total resistance of the parallel of the pots is around 1600 Ohms. The current the circuit will draw is I = U/R = 5 / 1600 = 0.003A = 3mA. It is not much, and the regulator will probably handle it well, but as said above, if you have the circuit battery powered, it might make a difference.
DeleteAlso I have been using 100K Pots with arduino without a problem. Normally Guitar Volume pedals use around that value. at least mine does.. :)
This comment has been removed by the author.
ReplyDeletecan i make this with "Arduino Mega" using this programming code ?
ReplyDeletei am using a mega and the buttons work but am having an issue with the pots,,,
DeleteI am also looking for Mega2560 program . Please if anyone has the solution , that I would be of great help.
ReplyDeletesorry for my english, i'm french!
Deletehi dave,,
ReplyDeletei 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
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
ReplyDeleteHi Terry. This code on;y works with the Arduino Uno. See the section under "Before you Start" for details.
DeleteI 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?
Deletehey 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
ReplyDeleteArduino: 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,};
ReplyDeletehi guys,
ReplyDeletei 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?
Hay varios programas para lograr dicha conversión, y tendrías que modificar el código en el Voip setup serialmidi
DeleteDoes it work with the midi mapping of VoiceMeeter Banana?
ReplyDeleteHello, 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!
ReplyDeleteis there an update on sysex potentiometer?
DeleteThis doesn't only just work with the UNO. I got it working with the Pro Mini.
ReplyDeleteHi - Thanx for a very nice job ;-)
ReplyDeleteI 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
This comment has been removed by the author.
ReplyDeleteIf anyone is wanting usb MIDI without the extra wiring (MIDI output/input) I had success with using hairless MIDI with loop MIDI.
ReplyDeleteI 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.
I try but is not working for me
DeleteThank you, you helped me
Deletehi
ReplyDeletewhere do you buy the knobs for your product.
I am having an hard time in finding them
im got error, help me :
ReplyDeleteArduino: 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
#include
^
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.
hey i got solution for yr problem ...dont change the midi library file name ..leave the names as you download it..if you change the Midi Library files name...fatal error: MIDI.h: No such file or directory will occur ..hope it will help
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehello is there a way to get this with a midi input?
ReplyDeleteSo I can connect this from my pc to my synth using the arduino as a CC controller?
Hello Dave, excellent project, I already mounted mine and it was great, congratulations and thanks for sharing with us, I would like to know if it is possible to modify the code to change the midi channels direct by the controller. Since I thank you (sorry my English, I am Brazilian and is translated).
ReplyDeleteFirst off all thank you for providing such a detailed video with step to step instructions. great thing!
ReplyDeleteI am curious if somebody in the end modified the code to use it with the Mega 2650? Because I saw there where some discussions about it. Or @Dave can you provide a code form the mega yet?
Hi, i wonder if there is a way how increase read of difference between old and new value on pots. So the pot will not react on small changes. the thing is that i have used cca 30 pots on mixconsole but some of them keep sending messages with very small change. I would like to make all of knobs bit less sensitive so when i want to learn midi knob in software it would not get milions of noise signals. I belive that has to do something with sheet controller.cpp but i am not sure witch part is it. Thank you for any idea
ReplyDeleteHi, I really appreciate the tutorials. I'm a complete beginner but I managed to set up the circuit. The problem is I'm trying to make a midi controller with pitch bend and I'm unsure how to modify what you've done to make that work. I'm eventually going to get a photo interrupter and encoder strip from a printer to control pitch bend but for now I'm sticking with your tutorial and using a POT. It looks like you left room for the command parameter to be customized but I don't know how. Any advice? Thanks!
ReplyDeletesame...
DeleteHi everyone. First sorry for my English,but I'm from Poland. I was bulid a Midi interface on Arduino Nano and if I used max 2 potentiometers with 74hc4051 they works good. But if I connected two multiplexer and 16 potentiometers - this project doesn't work good. Only first and 8nd a little work. Can U help to solve my problem?
ReplyDeleteHi, Dave, I got a keyboard to control and it was great. I would like to include an octave up and down octave. Would it be possible to add this in your code?
ReplyDeleteHi Dave,
ReplyDeleteI downloaded your Arduino MIDI Controller program. Thank you for sharing it!
Instead of a potentiometer I use a pressure sensor to control the Breath Controller CC Messages. But there is one little problem, in my MIDI Monitor I get low values even when i don’t blow in the sensor.
Is it possible to write some kind of threshold in the code? How can i do this?
Hi! I am making a system in wich i use your midi controller with two potenciometers to send signals to another arduino using your MIDI CC code, but a little changed, the result was fantastic and i wanted to know if there is a way to record the cc messages in a software using a midi interface in order to play them back to the arduino using the servos. Thank you very much
ReplyDeleteHi, Is there anybody has tried connect this to DAW software via USB MIDI cable? I have connected it by USB MIDI cable. The MIDI cc signal became none continued, CC signal only transmit one data each time I turn the knob. But it worked correctly when I connect it to my Synthsizer. I want to use it to control my able tone live. Is there any suggestion to connect PC which has no MIDI port?
ReplyDeleteI mentioned USB MIDI cable that is I bought it from China. The cable is USB to MIDI 5pin. I connected the 5 pin MIDI to the Arsuino. The USB to my computer.
Hello how can I modify the code, so Pot1 will send the message to few channels? Thank you, one of the best projects for Arduino!
ReplyDeleteHi, is this gonna work for the arduino uno I mean?
ReplyDeletetks for your help
Seby
https://www.amazon.ca/Elegoo-Project-Starter-Tutorial-Arduino/dp/B01D8KOZF4/ref=sr_1_2?s=electronics&ie=UTF8&qid=1543529352&sr=1-2&keywords=arduino+uno+kit
I have done everithing like it´s in the video but for some reason it doesn´t work. I have connected the arduino with a usb cable, and the midi with a USB/MIDI cable. I dont know why it doesn´t work. Can someone please help me?
ReplyDeletehi Dave. i am a super DIYer person. But i have never been so excited by making something by myself like this. Thanks a lot. for sharing software and tutorial. That was my dream to making my midi devices. İ d like to make a giant midi controller which has 128 potansiameters. Is that possible by using 8 multiplexer(8*16=128)?
ReplyDeleteAnd second, as many guys said before, please show us usb hub midi controller. Because most of us has only 1 midi in port on the sound card. and we can use many midi devices.
i ll be glad if u answer me.
Hi i'm currently using this project to help me get a grips on arduino midi and was wondering what purpose the "void newValue()" serves. any help and advice would be appreciated thanks.
ReplyDeleteJ
Hello,
ReplyDeletePlease explain how to add LED indication, when moving the pots...
What are the lines of code that limit it to the UNO?
ReplyDeleteThanks
Robin
everything works perfect until I connect potentiometer number 4, which sends midi signals constantly, even if I do not touch it.
ReplyDeleteWhat could be the problem?.
The potentiometer I'm using doesn't need to rotate 360 degrees, only about 180. Is it possible to 'calibrate' the code in some way to use the full 1024 MIDI steps, but only from half the pot rotation?
ReplyDeleteWow, I was trying to modify some of the plans for the groove sizer red for my own synth project because I thought that was a good starting point for what I wanted to accomplish. Hit many snags and had trouble following their code but with your tutorials I feel much more confident I will be able to build what I am wanting. Thank you so much for all the time you spent putting this together!!!
ReplyDeleteBefore i begin with my Question i want to thank you for your encouragement the website and oppertunity for us few nerds that want to build something like this on our own.
ReplyDeleteI want to build myself a Midi Controller with 6 Potentiometers and want to use your code. IS IT POSSIBLE to add a rotary switch so i can add 6 Banks. So i will be able to control 36 Knobs in my DAW? Do i need to use digital rotary encoders or is it possible to use my analog Potentiometers and still be able to change the address?
Thank you and Best regards Michael!
When i try t upload the code on a nano, it won't load, and states no file or directory MIDI.h, any pointers greatly appreciated
ReplyDeleteHi there how to make this project with more than 6 pot ?
ReplyDeleteHola.. es posible agregar a este código un lcd 16x2 para modificar los comandos, cc y ch midi?
ReplyDeletehello, any code to include encoder?
ReplyDeletethank you
MUITO OBRIGADO QUE MARAVILHA
ReplyDeleteMUITO GRATO
ReplyDeletehow could I modify the code to add a pitchbend control? (it would be a pot). thx!!
ReplyDeleteHi there, amazing work and website.
ReplyDeleteI was wondering if you had a project/code for a simple midi controller (Arduino Uno) using only 12 potentiometers (CC 1 to 127)
Please I have seen people writing different code on this page for mega 2560. I haven't start my project but I have some fears that Dave's code wouldn't work with my mega2560. So please if there is any solution so that we can use this code on atnega 2560 then make it a file and share it to as please.
ReplyDeleteTHANK YOU.
Hello, this mod worked better for me, since it works on any track selected, I have 8 sliders and had assigned them to 1-8, but can’t do anything to tracks 8 and over, I thought it could move like scenes, 1-8, 9-16, 17-24 etc, but couldn’t make it work, any suggestions? Thanks.
ReplyDeleteola, projeto muito bom, porem estou com oscilaçoes nos pots, ja soldei capacitores, me ajuda por favor.
ReplyDeleteWould you be interested in exchanging links?
ReplyDeleteDogforum.co.uk
Information
Click Here
Visit Web
Your place is valueble for me. Thanks!
ReplyDeleteThefastdiet.co.uk
Information
Click Here
Visit Web
hank you for all your explanation.
ReplyDeleteI would like to go further in your code to use encoders which would control cc's. I do not know how to do. THANKS
Thanks for your great teaching! You inspired me to learn this stuff, I just finished my first controller using your code? Works solidly!
ReplyDeleteHi, any help getting this to work on Arduino nano Every, I only want to use one pot. Help appreciated!
ReplyDelete