Potentiometer Send MIDI CC

Hello Everyone

I was wondering from the midi example that is available on Arduino Software
if its possible to send MIDI like that but with a potentiometer controlling both
Note and Velocity with different potentiometer's with serial.write

If there are examples available or someone that did something close to this
i would really appreciate your tips and solutions.

Thanks you very much

to send MIDI like that but with a potentiometer controlling both
Note and Velocity with different potentiometer's with serial.write

Yes it is almost trivial,
read the two pots into a variable and shift it 3 places to the right to scale it

vPot = analogRead(vPotPin) >> 3;
nPot = analogRead(nPotPin) >> 3;
// then do other stuff and final use these variables to send just after the note on

Hi i'm also trying to build up a controller with 8 pots using an arduino 2009 and a IC 4051 for multiplexing, i'm following this tutorial from littlescale

don't know why (maybe the pots) for me this circuit don't go. After that I've tested another circuit and code here it is

http://arduino.cc/forum/index.php/topic,122378.0.html

With that code and circuit I can hook up 6 pots (or analog sensor) and read their value, no latency, great response etc...

the problem is the mapping, when you select your parameter e.g. in ableton, until they are two it works than everything start flickering and its hard to get the solution....

this the code I've modify

#include <MIDI.h>
#define MIDI_ENABLE 12

// Variables:
int cc = 0;
int AnalogValue = 0; // define variables for the controller data
int lastAnalogValue = 0; // define the "lastValue" variables

void setup() {

// launch MIDI
MIDI.begin(4)
}

void loop() {
AnalogValue = analogRead(0);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(16,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;

AnalogValue = analogRead(1);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(17,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif

AnalogValue = analogRead(2);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(18,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif

}

I'm not a programmer, i'm not an electronic guru, i'm just a poor musician with a few of nerd skills :slight_smile:

On that first link, the code:-

if (filter[i] != data_send){ //if filter and data_send not equal then in theory this will only send midi data when a value is changes an not constantly.

Should be changed to:-

if (abs(filter[i] - data_send) > 1){ //if filter and data_send not equal then in theory this will only send midi data when a value is changes an not constantly.

This will allow a little bit of noise without constantly resending the MIDI

On that code you just posted you need a different variable for each analogue channel for both the value and the last value. As it is you are using the last value from the previous channel reading which is not going to work. While the code is rubbish change it to

AnalogValue0 = analogRead(0);
  //  convert to a range from 0 to 127:
  cc = AnalogValue0/8;
  // check if analog input has changed
  if (abs(lastAnalogValue0 - cc)>1 {
    MIDI.sendControlChange(16,cc,1);
    // update lastAnalogValue zero variable
    lastAnalogValue0 = cc;

AnalogValue1 = analogRead(1);
  //  convert to a range from 0 to 127:
  cc = AnalogValue1/8;
  // check if analog input has changed
  if (abs(lastAnalogValue1 - cc)>1 {
    MIDI.sendControlChange(16,cc,1);
    // update lastAnalogValue one variable
    lastAnalogValue1 = cc;

// and so on

Hi, I was doing something similar, and using arrays it's a simpler and more elegant way to do the task:

#include <MIDI.h>

//Define Pots
byte cc = 0;
byte pot[] = {0, 0, 0, 0, 0, 0, 0, 0};
byte lastpot[] = {0, 0, 0, 0, 0, 0, 0, 0};
//Define cc number of each pot
byte midi_cc[] = {10, 60, 23, 16, 34, 45, 33, 78};

void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
  for (byte i = 0; i < 8; i++)
  {
    pot[i] = analogRead(i);
    cc = pot[i] / 8;
    if (lastpot[i] != cc) {
      MIDI.sendControlChange(midi_cc[i],cc,1);
      lastpot[i] = cc;
    }
  }
}

An update on the previous code.
No new concepts, just a smarter way to remap from AI's 1024 to MIDI's 256 steps:

#include <MIDI.h>

//Define Pots
byte pot[] = {0, 0, 0, 0, 0, 0, 0, 0};
byte lastpot[] = {0, 0, 0, 0, 0, 0, 0, 0};
//Define cc number of each pot
byte midi_cc[] = {10, 60, 23, 16, 34, 45, 33, 78};

void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
  for (byte i = 0; i < 8; i++)
  {
    pot[i] = analogRead(i) >>3;
    if (lastpot[i] != pot[i]) {
      MIDI.sendControlChange(midi_cc[i],pot[i],1);
      lastpot[i] = pot[i];
    }
  }
}

to MIDI's 256 steps:

But a MIDI data message has only 128 steps. Which is what your code does.