simple 6 pot arduino midi-over-USB-controller

Hi, I really need som help figuring this one out. I feel stupid, It surley is something very simple that Ive missed.

1:

I got 6 pots connected to Arduino UNO, my program reads the pots, divide results with 8

and sends BYTES with “0xB0” + “potnumber” +“potvalue” (se posted code).

2:

I put the Arduino in DFU-mode and run the USBdevice dot BAT file “makeMidi.bat”.

3:

Arduino shows up as an MIDI-device.

4:

I open Ableton to MAP a Pot to the volume-controller.

5:

Each time i do this It works and map the pot to the volume-slider, but instead of scrolling the volume slider up/down

It changes the pitchbend from 8/16 to 16/16.

6:

Ive tried my own code plus 3 other codes that I found online only to get the same results.

7 :

Ive tried to re-write the midi-message in several ways, Ive tried both “serial.write” and “serial.print” and sending one “empty” byte between

And always get the same results.


My only thougt is that it has something to do with the signal/BYTE being sent in a diffrent way when i turn the arduino into a MIDI-device.


This is the last code I tested, got it online from some forum, anyways:


#include <MIDI.h>

// MIDI enable pin, avoids conflict of Serial between USB for programming and DIN MIDI I/O
#define MIDI_ENABLE 12

// Variables:
int input_nb = 6; // select number of desired analog inputs (max 6)
int AnalogValue[6] = {0,0,0,0,0,0}; // define variables for the controller data
int lastAnalogValue[6] = {0,0,0,0,0,0}; // define the "lastValue" variables
int midiCCselect[6] = {22,23,24,25,26,27}; // select the midi Controller Number for each input (22 to 31 are free)
int thresh[6] = {1,1,1,1,1,1}; // select threshold for each analog input

void setup() {
 MIDI.begin();   // MIDI lib, right baud  and so on
}

void loop() {
  for (int i =0; i < input_nb; i++) {
    //  My potentiometer gave a range from 0 to 1023:
    AnalogValue[i] = analogRead(i);
    //  convert to a range from 0 to 127:
    int cc = AnalogValue[i]/8;

    // check if analog input has changed
    if (cc != lastAnalogValue[i] ) {
      //send control change on cc#i
      midiCC(0xB0, midiCCselect[i], cc);
      //Serial.println(String(midiCCselect[i])+": "+String(cc));
      // update lastAnalogValue variable
      lastAnalogValue[i] = cc;
    }

  }  //  endfor
}

// sends a Midi CC. 
void midiCC(byte CC_data, byte c_num, byte c_val){
  Serial.write(CC_data);
  Serial.write(c_num);
  Serial.write(c_val);
  //Serial.print(CC_data);
  //Serial.print(c_num);
  //Serial.print(c_val);
}

Thank you!

It would appear that your 0xB0 is not being interpreted correctly. Why, I don’t know. I’m not keen on how you’ve declared midiCCselect[] and cc to be ints but told midiCC() that it’s arguments are bytes. But I doubt that’s the root problem. OTOH you tell midiCC() that the 1’st argument is a byte as well and then pass it a 0xB0 declared as an int. I wonder if the change from int to byte is happening properly. Just a guess …

thanks for the input! Im still tryign to solvit… 6h now haha… ok but I have some more things right now… went back to my old code. The arduino midi-liberary didnt work as well as anotherone i found…

Now I get a value from 1-126 but it’s CC notes!!!, Maj gadd!!!

I can do some stuff in ableton now… but still I cant manage to get te POTS to change the VOLUME!

new code:

#include <usbDevices.h>
#define numPots 6  // numer of pots
#define e 1        // this is the delta needed in
byte currentPot[6] = {0,0,0,0,0,0};    
byte pot[6] = {0,0,0,0,0,0}; 
byte controlChange = 0xB0;
void setup() {
  usb.init(midi);
}                         
void loop() {
  for(byte i=0; i<numPots; i++) {
    currentPot[i] = analogRead(i) / 8;    
    if(abs(currentPot[i]-pot[i]) > e) {
      sendMidi(controlChange, i+1, currentPot[i]);
      pot[i] = currentPot[i];
    }
  }
}

void sendMidi(byte controlChange, byte controlNum, byte val) {
  Serial.write(controlChange);
  Serial.write(controlNum);
  Serial.write(val);
  // Serial.write(byte(controlChange));
  //   Serial.write(byte(controlNum));
  //     Serial.write(byte(val));
  }

What Im doing wrong? :frowning:

Scenario 1: If I use arduinos MIDI lib , I get “pitchbend” 8/16 - 16/16 as a result in ableton

Scenario 2: if I dont use MIDI lib I get “CC notes” from 1-127 i ableton

(If I have any HEX outside “0xB0 - 0xBF” neither of scenerios works)

Ok, WHY cant i get the volumesliders to work?

tried diffrent HEXes but allways get the notechange

and when I use Arduinos MIDI liberary I allways get pitchbend instead.

http://www.lovebjorklund.se/image/img_hub/traktor2.jpg

http://www.lovebjorklund.se/image/img_hub/sd.jpg

Sounds like it’s time to learn the MIDI messaging protocol. I think we can assume that Abelton is acting properly on the message(s) it’s receiving. What must those messages be ? Is there some simple bit swap or other such error that could make the message you’re trying to send into those messages (CC notes and pitchbend) ? Comparing what you’re trying to send to the message(s) received may yield a clue.

The code you posted above didn’t use the MIDI library of functions. What happens when you do a :

sendControlChange (ControlNumber, ControlValue, Channel)

… instead of your MIDIcc() function ? All 3 of the arguments above are bytes.