increment an array with midi cc values

Hi all..

i have been building a synth based around the dsp g1 synth chip..

my design has 4 knobs to control 16 midi cc's

i have placed the midi ccs values into an array and i use a button to increment through but im having trouble and it doesnt seem to be working properly..

could someone share some information on the best way forward for incrementing an array with a button or potentiometer..

/*
 * edited from roguescience sketch
 * 
 *
 * digital pin 11 (OUTPUT/PWM) --> LED
 * digital pin 2 (INPUT) <-- button
 * analog pin 0 <-- pot
 * tx1 <-- pin 5 (5 PIN DIN aka MIDI jack)
 *
 * Send a MIDI note when the button is pressed and sends MIDI
 * CC data when a potentiometer is turned.
 */

int ledPin = 11;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin2 = 10;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin3 = 9;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin4 = 6;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int buttonPin = 2;               //choose the input pin for a pushbutton
//int buttonPin2 = 24;               //choose the input pin for a pushbutton

int potPin = 0;                  //choose the input pin for a potentometer
int potPin2 = 1;                  //choose the input pin for a potentometer 2 filter
int potPin3 = 2;                  //choose the input pin for a potentometer 3 
int potPin4 = 3;                  //choose the input pin for a potentometer 4 




int buttonVal = 0;                    //variable for reading the button status
int buttonState = 0;            //variable to hold the buttons current state
int bounceCheck = 0;            //variable for debouncing
                    
                    
                    //button 2 (different implimentaion)
                    
//int buttonVal2 = 0;               //variable for reading the button status
//int buttonState2 = 0;            //variable to hold the buttons current state
//int bounceCheck2 = 0;            //variable for debouncing

int potVal = 0;                //variable for reading potentiometer value
int potVal2 = 0;                //variable for reading potentiometer 2 filter value
int potVal3 = 0;                //variable for reading potentiometer 3 value
int potVal4 = 0;                //variable for reading potentiometer 3 value

int mappedPotVal = 0;          //variable for holding remapped pot filter value
int mappedPotVal2 = 0;          //variable for holding remapped pot 2 filter value
int mappedPotVal3 = 0;          //variable for holding remapped pot 3 value
int mappedPotVal4 = 0;          //variable for holding remapped pot 3 value

int prevPotVal = 0;               //variable for storing our prev pot value
int prevPotVal2 = 0;               //variable for storing our prev pot value
int prevPotVal3 = 0;               //variable for storing our prev pot value
int prevPotVal4 = 0;               //variable for storing our prev pot value   LAST PHYSICAL POT

int THRESHOLD = 2;            //threshold amount

             
              //MIDI menu Button CODE 

            const byte buttonPin2 = 5;
            byte previousButtonState2 = HIGH;
            byte currentButtonState2 = HIGH;
            byte index = 0;  //initial value of the index
 
                          //midi menu button (diferent implimentation)
                          
  //pinMode(buttonPin2, INPUT);                         //declare pushbutton as input


void setup() {
  pinMode(ledPin, OUTPUT);          //declare LED as output
   pinMode(ledPin2, OUTPUT);           //declare LED as output
   pinMode(ledPin3, OUTPUT);              //declare LED as output
    pinMode(ledPin4, OUTPUT);                 //declare LED as output
  pinMode(buttonPin, INPUT);                         //declare pushbutton as input
  
  
                          //midi menu button diiferent implimentation
                          
  //pinMode(buttonPin2, INPUT);                         //declare pushbutton as input
  
                   //MIDI menu CODE
  
             pinMode(buttonPin2, INPUT_PULLUP);
             
             
  Serial.begin(31250);              //MIDI communicates at 31250 baud
}

void loop(){

  buttonVal = digitalRead(buttonPin);              //read input value from button
    delay(10);                                      //wait 10ms
  bounceCheck = digitalRead(buttonPin);             //check again
     if(buttonVal == bounceCheck){                  //if val is the same then not a bounce
        if (buttonVal == HIGH && buttonState == 1)    {   //check if the input is HIGH
           digitalWrite(ledPin, LOW);                       //turn LED OFF
              midiOUT(0x90, 1, 0);                   //Note ON (CH 1), middle C, zero velocity turns note off
                buttonState = 0;
    }
    if(buttonVal == LOW && buttonState == 0){
      digitalWrite(ledPin, HIGH);       //turn LED ON
          midiOUT(0x90, 1, 127); //Note ON (CH 1), middle C, velocity 127
             buttonState = 1;
    }
/*
{
                     midi menu button (
                     
                     different implementation)
  buttonVal2 = digitalRead(buttonPin2);              //read input value from button
    delay(10);                                      //wait 10ms
  bounceCheck = digitalRead(buttonPin2);             //check again
     if(buttonVal2 == bounceCheck){                  //if val is the same then not a bounce
        if (buttonVal2 == HIGH && buttonState == 1)    {   //check if the input is HIGH
           digitalWrite(ledPin, LOW);                       //turn LED OFF
              midiOUT(0x90, 1, 0);                   //Note ON (CH 1), middle C, zero velocity turns note off
                buttonState = 0;
    }
    if(buttonVal == LOW && buttonState == 0){
      digitalWrite(ledPin, HIGH);       //turn LED ON
          midiOUT(0x90, 1, 127); //Note ON (CH 1), middle C, velocity 127
             buttonState = 1;
    }
    */
  }
  
                //MIDI BUTTON CODE
{
     currentButtonState2 = digitalRead(buttonPin2);
        if (currentButtonState2 != previousButtonState2 && currentButtonState2 == LOW)  //button has become pressed
  {
       index++;
        index = index % 4;  //roll over to zero when it reaches 4
                Serial.println(index);
  }
          previousButtonState2 = currentButtonState2;
}
                // POT 1  CODE
                
   byte midicc[] = {73, 74, 16, 76};   //ARRAY
     potVal = analogRead(potPin);                            //read input from potentiometer
       mappedPotVal = map(potVal, 0, 1023, 0, 127);          //map value to 0-127
        if(abs(mappedPotVal - prevPotVal) >= THRESHOLD){
          midiOUT(0xB0, midicc[index], mappedPotVal);         //Control Change (Ch 1), Controller 7 - default control for volume.
            digitalWrite(ledPin, HIGH);    
               prevPotVal = mappedPotVal;
   }
   else{
      digitalWrite(ledPin, LOW);
   }
   
                //POT 2 CODE
                
  byte midicc2[] = {75, 71, 20, 04};                             //ARRAY
    potVal2 = analogRead(potPin2);                           //read input from potentiometer
     mappedPotVal2 = map(potVal2, 0, 1023, 0, 127);          //map value to 0-127
      if(abs(mappedPotVal2 - prevPotVal2) >= THRESHOLD){
        midiOUT(0xB0, midicc2[index], mappedPotVal2);        //Control Change (Ch 1), Controller 7 - default control for volume.
         digitalWrite(ledPin2, HIGH);
           prevPotVal2 = mappedPotVal2;
   }
   else{
      digitalWrite(ledPin2, LOW);
   }
   
               //POT 3 CODE
               
  byte midicc3[] = {31, 01, 82, 21};
    potVal3 = analogRead(potPin3);                            //read input from potentiometer
       mappedPotVal3 = map(potVal3, 0, 1023, 0, 127);         //map value to 0-127
         if(abs(mappedPotVal3 - prevPotVal3) >= THRESHOLD){
            midiOUT(0xB0, midicc3[index], mappedPotVal3);     //Control Change (Ch 1), Controller 7 - default control for volume.
             digitalWrite(ledPin3, HIGH);
                prevPotVal3 = mappedPotVal3;
   }
   else{
      digitalWrite(ledPin3, LOW);
   }
   
                //POT 4 CODE
                
   byte midicc4[] = {72, 16, 81, 93};  
     potVal4 = analogRead(potPin4);                           //read input from potentiometer
       mappedPotVal4 = map(potVal4, 0, 1023, 0, 127);         //map value to 0-127
         if(abs(mappedPotVal4 - prevPotVal4) >= THRESHOLD){
           midiOUT(0xB0, midicc4[index], mappedPotVal4);       //Control Change (Ch 1), Controller 7 - default control for volume.
            digitalWrite(ledPin4, HIGH);
              prevPotVal4 = mappedPotVal4;
   }
   else{
      digitalWrite(ledPin4, LOW);
   }
 
}

         void midiOUT(byte command, byte value1, byte value2) {
          Serial.write(command);
           Serial.write(value1);
             Serial.write(value2);

}

whats
with
all
the
angled
indentation?

You do not increment an array, you might want to increment the index into an array but that is something different.

buttonVal = digitalRead(buttonPin);              //read input value from button
    delay(10);                                      //wait 10ms
  bounceCheck = digitalRead(buttonPin);             //check again
     if(buttonVal == bounceCheck){                  //if val is the same then not a bounce
        if (buttonVal == HIGH && buttonState == 1)    {   //check if the input is HIGH

Is not the way to do anything. Read the input from a button, it has to be high and the last time you read it has to be low and then you pay attention to it. Don't bother with debounce at this stage until you know you need it, you most likely will not need it as you get natural debounce delay between reads fro sending the MIDI messages.

When you find your self writing the same code over and over that is God's way of telling you that you need to learn more about code. In your case that code is arrays. You already know a bit about them but you need to put all your analogue readings and digital readings into arrays so that one piece of code can be made to work for all four pots and push buttons.

Where are your code examples G-Mike?

What code examples? I have lots.