Midi controller - 5 Pots - Pro Micro - HELP (newbie)

Hi there
Problem
I am trying to build a 5 potentiometer midi controller using a Arduino pro micro in order to use "MIDImixer" instead of "Deej" to control Window's volume mixer, but having some issues due to my lack of understanding on how to modify an existing code to suit my build.

Reference:
The project originates from Adam Welch's youtube build ( deej - Arduino Volume Mixer )
Video link:

https://www.youtube.com/watch?v=9WqwH4tebzI&ab_channel=AdamWelch

He uses an Arduino Nano. I did try one, but the nano board i have doesn't seem to respond when checking the serial monitor and turning the pots. Bought it from Aliexpress and wondering if it is a dudd, perhaps a Pro Micro could do the job instead...

Question:

  1. Would it be possible to modify the code to work with a ProMicro instead?
  2. If yes, would anyone from this forum be able to help me navigate this change in code, please?

Libraries i have installed:
#include <MIDI_Controller.h>
#include <MIDIUSB.h>
#include <MIDIUSB_Defs.h>
#include <frequencyToNote.h>
#include <pitchToFrequency.h>
#include <pitchToNote.h>

Adam's code used from the Deej Github

const int NUM_SLIDERS = 5;
const int analogInputs[NUM_SLIDERS] = {A0, A1, A2, A3, A4};

int analogSliderValues[NUM_SLIDERS];

void setup() { 
  for (int i = 0; i < NUM_SLIDERS; i++) {
    pinMode(analogInputs[i], INPUT);
  }

  Serial.begin(9600);
}

void loop() {
  updateSliderValues();
  sendSliderValues(); // Actually send data (all the time)
  // printSliderValues(); // For debug
  delay(10);
}

void updateSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
     analogSliderValues[i] = analogRead(analogInputs[i]);
  }
}

void sendSliderValues() {
  String builtString = String("");

  for (int i = 0; i < NUM_SLIDERS; i++) {
    builtString += String((int)analogSliderValues[i]);

    if (i < NUM_SLIDERS - 1) {
      builtString += String("|");
    }
  }
  
  Serial.println(builtString);
}

void printSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    String printedString = String("Slider #") + String(i + 1) + String(": ") + String(analogSliderValues[i]) + String(" mV");
    Serial.write(printedString.c_str());

    if (i < NUM_SLIDERS - 1) {
      Serial.write(" | ");
    } else {
      Serial.write("\n");
    }
  }
}

Picture of my build:

Wiring:
A0 - Pot 1 - Brown
A1 - Pot 2 - Red
A2 - Pot 3 - Orange
A3 - Pot 4 - Yellow
A9 - Pot 5 - Green

Gnd - White
VCC (5V) - Orange 2

Conclusion:
Not sure how difficult this request is, I have tried using Nerd Musician's midi controller guide but the codes he uses and guide confuses the hell out of me at this stage of my learning.

Any help would be much appreciated.
TIA!

It would help a lot if You draw schematics. Pen and paper often works well. There's too much of detective work to use the pictures.

In which case you can take some of the example programs to test. Blink, AnalogInSerialOut etc and try to figure that out.

You will need to adjust the analogInputs array to reflect the changes that you made; the Pro Micro does not have an A4 and you have connected a wire to A9.

Thanks, would this be better?

Yes, A9 instead of A4.

Theoretically, could a "nano" board code be uploaded to a "Pro micro" board without changes to the code?
I would imagine different libraries would be needed?

And thank you.
I ran those tests, but either get stuck in "uploading" forever with a red led.. not sure what that means other than without an upload a code is uselss

Much better but I wish You had inluded the powering as well. Without the proper powering, it will not work the way You want.

Powering, like via usb cable connected to a PC?

You have to recompile. The correct stuff will be included in the background for you.

What are the values of the potmeters?

Start with a simple example like this.

void setup()
{
Serial.begin(115200);
while(!Serial);

Serial.println("hello world");
}

void loop()
{
}

Does it print hello world,

On the Nano, it can't complete the upload. Tried different USB ports, same story.

On the Pro Micro, this code uploads but nothing shows in the serial monitor.
This message is shown in the output

Sketch uses 3608 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 163 bytes (6%) of dynamic memory, leaving 2397 bytes for local variables. Maximum is 2560 bytes.
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

not sure what this means

Thanks. Seems the code is now running fine on the Pro Micro which enables me to run Deej.

Midi Mixer still doesn't work with this code. Will have to find something else. Leaving the project here for now.

Thank you for taking the time to help!

Have a proper look at Control surface library for creating a midi mixer or any other controller. The micro is the preferred choice for it since it has native USB, which will enable you to make your device a USB-midi device, and it has another UART ! keep that in mind while migrating code though. The USB Serial does not have the pins exposed on the micro, just UART1 has pins exposed.

Have you tried the different processor options in the tools menu?

It's the end of the upload process and to my knowledge it means success. I have only seen this in IDE2.0.x. If you're using that, you have to pay attention to the notifications in the right bottom.

Have you tried the different processor options in the tools menu?

Are you referring to the "programmer" option?
TBH, I have no idea what these options do. I have been selecting AVRISPmkII as default

It's the end of the upload process and to my knowledge it means success. I have only seen this in IDE2.0.x. If you're using that, you have to pay attention to the notifications in the right bottom.

the message at the end is in RED which seems something is wrong.

I tried writing a basic code based on Michael Sobolak's tutorial to use the 5 pots as generic controllers. When "verifying" the code it seems okay, but when trying to upload it gives the same red notice.
Code tut Reference: https://www.youtube.com/watch?v=zIkHvzbVkmA&list=PLrse6DrMCoqTtYXEZkvQhr47U16Bd6R6S&index=2&t=7s&ab_channel=MichaelSobolak

After uploading, there is no activity in the serial monitor.
Scared to ask, but am I, or rather how much am I missing here? :sweat_smile:

#include <MIDI_Controller.h>

Analog potentiometer1(A0, MIDI_CC::Channel_Volume, 1);
Analog potentiometer2(A1, MIDI_CC::Channel_Volume, 2);
Analog potentiometer3(A2, MIDI_CC::Channel_Volume, 3);
Analog potentiometer4(A3, MIDI_CC::Channel_Volume, 4);
Analog potentiometer5(A9, MIDI_CC::Channel_Volume, 5);

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
MIDI_Controller.refresh();
}


No. For the Nano, tools -> processor. There are three options, try each till you find a working one.

The programmer options only apply whe you use "upload using programmer".

No fear, well we are missing

MIDI_Controller.h
1 Like

thx, but im giving up on the Nano...trying to upload to the Micro which would be better for plug and play i hear.

besides, the Nano seems completely bricked no matter the programmer / Processor (board = Arduino Nano)

seems this code is a common issue which no one really knows why.

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

It's a normal message, it's not an issue !! Ignore it

1 Like

SOLVED UPDATE:

After getting the code to work and posting here today i opened another thread to look into why the controller is not being picked up by FL studio. (ref: DIY Midi controller - FL studio no device detection - #2 by PieterP)

Peter P pointed out that the controller tries to use MIDI over Serial, not MIDI over USB.
He also supplied code to use: Control Surface: Multiple-Control-Change-Potentiometers.ino

The controller now with Midi-Mixer and in the DAW.

Thank all for your insight. A massive help to newbies like me.
Take care!

Below post from earlier:

Thank you all for the reply.

Had to step away from this project, though I've managed to get a working code with some modifications using ChatGPT.

It seems the controller is being recognized by Windows (device manager) and getting a good consistent read on the IDE 2.0.3 - serial monitor.

For some reason Applications like FL Studio and Midi-mixer does not detect the midi device which is a bit of a head scratch. Any ideas why that might be?

Here is the updated code by the bot:

#include <MIDI.h>

const int potPin1 = A0;
const int potPin2 = A1;
const int potPin3 = A2;
const int potPin4 = A3;
const int potPin5 = A9;

int potVal1 = 0;
int potVal2 = 0;
int potVal3 = 0;
int potVal4 = 0;
int potVal5 = 0;

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
  pinMode(potPin1, INPUT);
  pinMode(potPin2, INPUT);
  pinMode(potPin3, INPUT);
  pinMode(potPin4, INPUT);
  pinMode(potPin5, INPUT);
  MIDI.begin();
  
  // Initialize Serial Communication
  Serial.begin(9600);
}

void loop() {
  potVal1 = analogRead(potPin1);
  potVal2 = analogRead(potPin2);
  potVal3 = analogRead(potPin3);
  potVal4 = analogRead(potPin4);
  potVal5 = analogRead(potPin5);

  //Send MIDI control change message for each potentiometer
  MIDI.sendControlChange(1, map(potVal1, 0, 1023, 0, 127), 1);
  MIDI.sendControlChange(2, map(potVal2, 0, 1023, 0, 127), 1);
  MIDI.sendControlChange(3, map(potVal3, 0, 1023, 0, 127), 1);
  MIDI.sendControlChange(4, map(potVal4, 0, 1023, 0, 127), 1);
  MIDI.sendControlChange(5, map(potVal5, 0, 1023, 0, 127), 1);
  
  // Send potentiometer values to serial monitor
  Serial.print("Potentiometer 1: ");
  Serial.println(potVal1);
  Serial.print("Potentiometer 2: ");
  Serial.println(potVal2);
  Serial.print("Potentiometer 3: ");
  Serial.println(potVal3);
  Serial.print("Potentiometer 4: ");
  Serial.println(potVal4);
  Serial.print("Potentiometer 5: ");
  Serial.println(potVal5);
  Serial.println();
  delay(100);
}

Then you have to use a different library. Within control surface there is the option to use USB-midi, and i use MIDIUSB.h which use a different structure. But it works also as a midi-usb device and shows up in any DAW that i have and all of NI standalone.

1 Like