Fehler im Sketch aber wo???

Ja, das geht!

Hier mal nur das Taster/Debounce Gedöns überarbeitet, den Rest habe ich stumpf übernommen.

und völlig ungetestet

int controlChange = 176; // MIDI Kanal 1
 int controllerNummer [] = {50,51,52,53};
 int controllerWert []= {0,0,0,0};
 int controllerWertAlt []= {0,0,0,0};
 int potiWert []= {0,0,0,0};

// LED Abfrage Midi Empfang
byte commandByte ; //Midi Empfang Daten Channal 1
byte channelByte;  //Midi Daten CHxx
byte statusByte;   //Midi Daten Status
byte cc = 176;

void sendeMIDI(int statusByte, int dataByte1, int dataByte2);
void potisAbfragen(byte x,byte y,int analogPin);
void SerialLesen();
void checkMIDI();

#include <Bounce2.h>

class Taster
{
  private:
  byte pin;
  byte Nummer;
  bool tasteAlt = false;
  bool tasteGedrueckt = false;
  Bounce debounce;

  public:
  Taster(byte pin,byte Nummer):pin(pin),Nummer(Nummer){}
  
  void init()
  {
    pinMode(pin,INPUT);
    debounce.attach(pin);
    debounce.interval(5); // interval in ms
  }
  
  void run()
  {
      debounce.update();  //debouncer
         
      bool taste = debounce.read();
      if (taste == HIGH && tasteAlt == LOW) 
      {
        if (tasteGedrueckt == false)  
        { 
          sendeMIDI(176,Nummer, 127);
          tasteGedrueckt = true; 
        }
        else 
        { 
          sendeMIDI(176, Nummer, 0);
          tasteGedrueckt = false;
        }
      }
      tasteAlt= taste;    
  }
};

Taster taster[] = {
                    {22,22},
                    {23,23},
                    {24,24},
                    {25,25},
                    {26,26},
                    {27,27},
                   } ; 


void setup() {
 Serial.begin(9600);
 Serial1.begin(31250); //Midi Ausgang
 Serial2.begin(31250); //Midi Eingang
 for(Taster & taste:taster) taste.init();
 

pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (11, OUTPUT);

}

void loop() 
{
  
  SerialLesen();
  checkMIDI();
   
  //potisAbfragen(0,0,A0);
  //potisAbfragen(1,1,A1);
  //potisAbfragen(2,2,A2);
  potisAbfragen(3,3,A3);
  
  for(Taster & taste:taster) taste.run();
  
}

void checkMIDI()
{ 

if ((commandByte == cc)&& (channelByte == 22)&& (statusByte == 1)){digitalWrite(8,HIGH);}
if ((commandByte == cc)&& (channelByte == 22)&& (statusByte == 0)){digitalWrite(8,LOW);}

if ((commandByte == cc)&& (channelByte == 23)&& (statusByte == 1)){digitalWrite(9,HIGH);}
if ((commandByte == cc)&& (channelByte == 23)&& (statusByte == 0)){digitalWrite(9,LOW);}

if ((commandByte == cc)&& (channelByte == 24)&& (statusByte == 1)){digitalWrite(10,HIGH);}
if ((commandByte == cc)&& (channelByte == 24)&& (statusByte == 0)){digitalWrite(10,LOW);}

if ((commandByte == cc)&& (channelByte == 25)&& (statusByte == 1)){digitalWrite(11,HIGH);}
if ((commandByte == cc)&& (channelByte == 25)&& (statusByte == 0)){digitalWrite(11,LOW);}
}          

void SerialLesen()  {
      
                                            
 if     (Serial2.available()==1)              {   
              commandByte = Serial2.read();
            Serial.println (commandByte);
            delay (1);
            channelByte = Serial2.read();
            Serial.println (channelByte);
            delay (1);
            statusByte = Serial2.read();
            Serial.println (statusByte);
      
             {
       
     while (Serial2.available() ==3);  
     } }}
 

  
void potisAbfragen(byte x,byte y,int analogPin){
       potiWert[x] = analogRead(analogPin);
 controllerWert[x] = map(potiWert[x],0,1023,0,127);

 if (controllerWert[x] != controllerWertAlt[x]) {
    sendeMIDI(controlChange, controllerNummer[y], controllerWert[x]); }
    controllerWertAlt[x] = controllerWert[x];}

    
void sendeMIDI(int statusByte, int dataByte1, int dataByte2) 
{
 Serial1.write(statusByte);
 Serial1.write(dataByte1);
 Serial1.write(dataByte2);
}

{22,22}, <<-- da scheint mir noch was überflüssig zu sein. zumindest solange Pin und Nummer gleich bleiben sollen.