MIDI library not sending CC values.

Hi, i've started experimenting with arduino a couple of weeks ago, my project is a DJ software MIDI controller, i'm using different chunks of code from around for different purposes (rotary encoders, LED outputs, analog ins) i tried different MIDI message handling methods but found the "MIDI library v3.1" Arduino Playground - MIDILibrary the most convenient, now i'm trying to send midi CC values ( MIDI.send(ControlChange,01, rotPotVal, 01)) but i just get 1 message when i move the pot and it stuck until i send a "note on/off" with the rotary encoder. I discovered before that the library won't allow you to repeat the same "note off" or "note on" without its corresponding on/off first, could that be the case with the CCs too? if so, what workaround would you suggest?
Please forgive me if the code is a mess, i'm just experimenting with the small different parts to later unite everything.

Here is the library reference: Arduino MIDI Library: MIDI_Class Class Reference

/* Rotary encoder read example w. midi*/
#include <MIDI.h>
#define ENC_A 8
#define ENC_B 9
#define ENC_PORT PINB
int count;
//X
//connect the middle rotary potentiometer pin to the corresponding Arduino analog ins
//connect the outside rotary potentiometer pins to power and ground
int rotPotIn = 0; //analog in 0
//initial value set to zero
int rotPotVal = 0;
int rotPotValPrev = 0;
//X

 
void setup()
{
  /* Setup encoder pins as inputs */
  pinMode(ENC_A, INPUT);
  digitalWrite(ENC_A, HIGH);
  pinMode(ENC_B, INPUT);
  digitalWrite(ENC_B, HIGH);
  
  //initialize MIDI
  MIDI.begin(); 
}
 
void loop()
{ //X rot encoder
  static uint8_t counter = 0;      //this variable will be changed by encoder input
 int8_t tmpdata;
 /**/
  tmpdata = read_encoder();
  if( tmpdata ) {
    //X
    if( tmpdata ) {
if( tmpdata == 1 ) {
count++;}
if (count==2){
MIDI.send(NoteOn,40,127,1);
count =0;
MIDI.send(NoteOff,40,0,1);
}

if( tmpdata == -1 ){
  count--;}
if (count==-2){
MIDI.send(NoteOn,40,1,1);
count =0;}
MIDI.send(NoteOff,40,0,1);
}
  
    counter += tmpdata;
  }

  //X Potentiometer
   rotPotVal = map(analogRead(rotPotIn), 0, 1023, 0, 127); //read value and remap the range for MIDI
  if(abs(rotPotVal-rotPotValPrev)>2){ //only send MIDI messages when value has changed by threshold of 2
  MIDI.send(ControlChange,01, rotPotVal, 01); //Chan 1 contol change, controller number, controller value,channel
  rotPotValPrev = rotPotVal; //reset value
  MIDI.send(
  }
//X
}  
  

 
/* returns change in encoder state (-1,0,1) */
int8_t read_encoder()
{
  static int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
  
 
  
}

Ok, i figured out.
In the library MIDI.h thre's a series of definitions for you to customize the library for your needs.

00001 
00011 #ifndef LIB_MIDI_H_
00012 #define LIB_MIDI_H_
00013 
00014 #include <inttypes.h> 
00015 
00016 
00017 /*  
00018     ###############################################################
00019     #                                                             #
00020     #    CONFIGURATION AREA                                       #
00021     #                                                             #
00022     #    Here are a few settings you can change to customize      #
00023     #    the library for your own project. You can for example    #
00024     #    choose to compile only parts of it so you gain flash     #
00025     #    space and optimise the speed of your sketch.             #
00026     #                                                             #
00027     ###############################################################
00028  */
00029 
00030 
00031 #define COMPILE_MIDI_IN         1           // Set this setting to 1 to use the MIDI input.
00032 #define COMPILE_MIDI_OUT        1           // Set this setting to 1 to use the MIDI output. 
00033 #define COMPILE_MIDI_THRU       1           // Set this setting to 1 to use the MIDI Soft Thru feature
00034                                             // Please note that the Thru will work only when both COMPILE_MIDI_IN and COMPILE_MIDI_OUT set to 1.
00035 
00036 
00037 #define USE_SERIAL_PORT         Serial      // Change the number (to Serial1 for example) if you want
00038                                             // to use a different serial port for MIDI I/O.
00039 
00040 
00041 #define USE_RUNNING_STATUS      1           // Running status enables short messages when sending multiple values
00042                                             // of the same type and channel.
00043                                             // Set to 0 if you have troubles with controlling you hardware.
00044 
00045 
00046 #define USE_CALLBACKS           1           // Set this to 1 if you want to use callback handlers (to bind your functions to the library).
00047                                             // To use the callbacks, you need to have COMPILE_MIDI_IN set to 1
00048 
00049 
00050 // END OF CONFIGURATION AREA 
00051 // (do not modify anything under this line unless you know what you are doing)
00052 
00053 
00054 #define MIDI_BAUDRATE           31250
00055 
00056 #define MIDI_CHANNEL_OMNI       0
00057 #define MIDI_CHANNEL_OFF        17 // and over
00058 
00059 #define MIDI_SYSEX_ARRAY_SIZE   255

The parameter "#define USE_RUNNING_STATUS 1 " should be changed to "0"

Also you can change "#define MIDI_BAUDRATE 31250" to a higher one for USB midi

Now i have a different problem. Here's the new code, i've changed the analog pot code.

//X pot w timer
/*
   * Analogue input logic:
   * The Arduino uses a 10-bit (0-1023) analogue to digital converter (ADC) on each of its analogue inputs.
   * The ADC isn't very high resolution, so if a pot is in a position such that the output voltage is 'between'
   * what it can detect (say 2.505V or about 512.5 on a scale of 0-1023) then the value read will constantly
   * fluctuate between two integers (in this case 512 and 513).
   *
   * If we're simply looking for a change in the analogue input value like in the digital case above, then
   * there will be cases where the value is always changing, even though the physical input isn't being moved.
   * This will in turn send out a constant stream of MIDI messages to the connected software which may be problematic.
   *
   * To combat this, we require that the analogue input value must change by a certain threshold amount before
   * we register that it is actually changing. This is good in avoiding a constantly fluctuating value, but has
   * the negative effect of a reduced input resolution. For example if the threshold amount was 2 and we slowly moved
   * a slider through it's full range, we would only detect every second value as a change, in effect reducing the
   * already small 7-bit MIDI value to a 6-bit MIDI value.
   *
   * To get around this problem but still use the threshold logic, a timer is used. Initially the analogue input
   * must exceed the threshold to be detected as an input. Once this occurs, we then read every value coming from the
   * analogue input (not just those exceeding a threshold) giving us full 7-bit resolution. At the same time the
   * timer is started. This timer is used to keep track of whether an input hasn't been moved for a certain time
   * period. If it has been moved, the timer is restarted. If no movement occurs the timer is just left to run. When
   * the timer expires the analogue input is assumed to be no longer moving. Subsequent movements must exceed the
   * threshold amount.
   */
 for (i = 0; i < NUM_AI; i++)
  {
    // Read the analogue input pin, dividing it by 8 so the 10-bit ADC value (0-1023) is converted to a 7-bit MIDI value (0-127).
    tempAnalogueInput = analogRead(analogueInputMapping[i]) / 8;
    
    #ifdef ANALOGUE_FILTER
    // Take the absolute value of the difference between the curent and new values 
    analogueDiff = abs(tempAnalogueInput - analogueInputs[i]);
    // Only continue if the threshold was exceeded, or the input was already changing
    if ((analogueDiff > 0 && analogueInputChanging[i] == true) || analogueDiff >= FILTER_AMOUNT)
    {
      // Only restart the timer if we're sure the input isn't 'between' a value
      // ie. It's moved more than FILTER_AMOUNT
      if (analogueInputChanging[i] == false || analogueDiff >= FILTER_AMOUNT)
      {
        // Reset the last time the input was moved
        analogueInputTimer[i] = micros();
        
        // The analogue input is moving
        analogueInputChanging[i] = true;
      }
      else if (micros() - analogueInputTimer[i] > ANALOGUE_INPUT_CHANGE_TIMEOUT)
      {
        analogueInputChanging[i] = false;
      }
      
      // Only send data if we know the analogue input is moving
      if (analogueInputChanging[i] == true)
      {
        // Record the new analogue value
        analogueInputs[i] = tempAnalogueInput;
      
        // Send the analogue value out on the general MIDI CC (see definitions at beginning of this file)
      MIDI.send(ControlChange, i, analogueInputs[i], 1);
            
          }
    }
    #else
    if (analogueInputs[i] != tempAnalogueInput)
    {
      // Record the new analogue value
      analogueInputs[i] = tempAnalogueInput;
    
          // Send the analogue value out on the general MIDI CC (see definitions at beginning of this file)
      MIDI.send(ControlChange, i, analogueInputs[i], 1);
  
    }
    #endif
  }
  //X

in the part where i send the control change command "MIDI.send(ControlChange, i, analogueInputs_, 1);" if i leave it like that it sends the "analogueInputs*" over different controller numbers since it is defined by "i" and it is just a counter, how can i send just the controller that is changing?*_

Ok thanks for al repplies, :roll_eyes: I figured out myself, i just needed to ground all the not used analog ins as they where sending random noise as values.