How do I get full use of a potenteometer?

Hello all…

how would I go about using the full span of a potentiometer.

my project is a midi controller and I want to add 2 Pot Knobs to change the midi messages being sent from a button/finger drum pad.

This is the code that i have so far. I have tryed a few different versions but have not been successful in dividing the pot into the amount of midi messages in the array to then catch that number when the pot is turned.

in a perfect world I will eventually have all of the midi messages as a scroll able array so to speak.

A Corse Pot knob to get to the general message and a fine tune Pot knob to set a variable eg. velocity, after touch length, pitchbend

Now that i look at the code i can tell i am far off. The bit of code i have would be applyed to the fine tune pot.

Im still clueless on how to get full use of the potentiometer to scroll through all 8 sections of the array.

Can anybody help?

String cmds[8] = "Note On, Note Off, After Touch, Continuous Controller, Patch Change, Channel Pressure, Pitch Bend, Non-Musical Commands";

int val = analogRead(CMDpotPin);
          if ((val > 128) && (val < 255)) { 
      
      if (val > 144) {
      Serial.println("NoteOn ");
      Serial.println(val);
      } 
      Serial.println("NoteOff ");
      Serial.println(val);
      }[code/]

Here is a bit of code using switch case statements with ellipses to choose from a range of numbers. Note the use of character arrays instead of (hated for good reasons) String class.

const byte anaIn = A0;
char* message = "";
char* messageArray[8] = {
    "on", "off","medium","high","low","right","left","over"};

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    int potVal = analogRead(anaIn);
    switch(potVal)
    {
    case 0 ... 100:
        message = messageArray[0];
        break;
    case 101 ... 200:
        message = messageArray[1];
        break;
    case 201 ... 300:
        message = messageArray[2];
        break;
    case 301 ... 400:
        message = messageArray[3];
        break;
    case 401 ... 500:
        message = messageArray[4];
        break;
    case 501 ... 600:
        message = messageArray[5];
        break;
        case 601 ... 700:
        message = messageArray[6];
        break;
        case 701 ... 800:
        message = messageArray[7];
        break;
    default:
        message = "over range";
    }
    Serial.print(message);
    Serial.print("     ");
    Serial.println(potVal);
    delay(1000);
}

yes sir thx alot....

exactly what i needed..

@Nick: comments on the code generated for a switch/case using ellipses?