Arduino console midi

Ciao a tutti, e' da mesi che sto progettando questa console che manda segnali midi (per comunicare con questo protocollo con altre macchine, software etc..) con 130 pulsanti (di cui 24 indipendenti, ovvero che collego senza Multiplexer cosi da poterli cliccare insieme) 11 fader e 4 encoder.

Per il tutto ho ovviamente optato per arduino mega (atmega16u2 cosi da renderlo input midi a lavoro finito) , con 7 Multiplexer CD74HC4067 per i pulsanti che citavo prima, 11 potenziometri fader 10k SC6080GH e 4 encoder EC11.

Ora li sto testando ed ho trovato i seguenti problemi

  1. Potenziometri

I potenziometri non me li legge benissimo, a volte non arriva a 0-120 (come da codice) ma 0-117 oppure 2-120 etc

  1. Multiplexer

Finche si parla di un multiplexer tutto fila liscio come l'olio, ma quando ne aggiungo un'altro il secondo funziona male, riesco a leggere solo c6-c7-c14-c15(che comunque funzionano male) e non riesco a capire il perche e non trovo nulla su internet a riguardo

  1. Encoder

Per gli encoder nessun problema li devo solo aggiungere allo sketch

Spero di non essermi dimenticato nulla, se serve qualsiasi cosa sono A PIENA DISPOSIZIONE

Sono aperto anche a consigli che sicuramente siete piu esperti di me :3

Grazie in anticipo

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

int analogpot0 = A0; //knob 1
int analogpot1 = A1; //knob 1
int analogpot2 = A2;
int analogpot3 = A3;
int analogpot4 = A4;
int analogpot5 = A5;
int analogpot6 = A6;
int analogpot7 = A7;
int analogpot8 = A8;
int analogpot9 = A9;
int analogpot10 = A10;




int analogpot0Old = 0;
int analogpot1Old = 0;
int analogpot2Old = 0;
int analogpot3Old = 0;
int analogpot4Old = 0;
int analogpot5Old = 0;
int analogpot6Old = 0;
int analogpot7Old = 0;
int analogpot8Old = 0;
int analogpot9Old = 0;
int analogpot10Old = 0;


int analogpot0New = 0;
int analogpot1New = 0;
int analogpot2New = 0;
int analogpot3New = 0;
int analogpot4New = 0;
int analogpot5New = 0;
int analogpot6New = 0;
int analogpot7New = 0;
int analogpot8New = 0;
int analogpot9New = 0;
int analogpot10New = 0;


#define analogpot0CC 50
#define analogpot1CC 51
#define analogpot2CC 52
#define analogpot3CC 53
#define analogpot4CC 54
#define analogpot5CC 55
#define analogpot6CC 56
#define analogpot7CC 57
#define analogpot8CC 58
#define analogpot9CC 59
#define analogpot10CC 60


const int controlPin[4] = {2, 3, 4, 5};
//const int EN = 6; // che probabilmente non dovro' neanche usare, da testare anche senza perche ho visto alcuni che non se la inculano e la lasciano di default idk
const int sig1 = 6;
const int sig2 = 7;
const int sig3 = 8;
const int sig4 = 9;
const int sig5 = 10;
const int sig6 = 11;
const int sig7 = 12;

int button1 = 30;  
int button2 = 31;  
int button3 = 32; 
int button4 = 33;
int button5 = 34;
int button6 = 35;  
int button7 = 36;  
int button8 = 37; 
int button9 = 38;
int button10 = 39;
int button11 = 40;  
int button12 = 41;  
int button13 = 42; 
int button14 = 43;
int button15 = 44;
int button16 = 45;  
int button17 = 46;  
int button18 = 47; 
int button19 = 48;
int button20 = 49;
int button21 = 50;  
int button22 = 51;  
int button23 = 52; 
int button24 = 53;


const int multiplexer[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };

const int multiplexer2[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };

const int multiplexer3[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };

const int multiplexer4[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };

const int multiplexer5[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };
                                                  
 const int multiplexer6[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };
                         
const int multiplexer7[16][4] = { {0,0,0,0}, //canale 0
                           {0,0,0,1}, //canale 1
                           {0,0,1,0}, //canale 2
                           {0,0,1,1}, //canale 3
                           {0,1,0,0}, //canale 4
                           {0,1,0,1}, //canale 5
                           {0,1,1,0}, //canale 6
                           {0,1,1,1}, //canale 7
                           {1,0,0,0}, //canale 8
                           {1,0,0,1}, //canale 9
                           {1,0,1,0}, //canale 10
                           {1,0,1,1}, //canale 11
                           {1,1,0,0}, //canale 12
                           {1,1,0,1}, //canale 13
                           {1,1,1,0}, //canale 14
                           {1,1,1,1}  //canale 14
                         };
                         



// MIDI.sendControlChange (0,32,2);  //(NoteNumber, Velocity, Channel
void setup() {
  
  MIDI.begin ();

  
  pinMode(button1,INPUT_PULLUP);
  pinMode(button2,INPUT_PULLUP);
  pinMode(button3,INPUT_PULLUP);
  pinMode(button4,INPUT_PULLUP);
  pinMode(button5,INPUT_PULLUP);
  pinMode(button6,INPUT_PULLUP);
  pinMode(button7,INPUT_PULLUP);
  pinMode(button8,INPUT_PULLUP);
  pinMode(button9,INPUT_PULLUP);
  pinMode(button10,INPUT_PULLUP);
  pinMode(button11,INPUT_PULLUP);
  pinMode(button12,INPUT_PULLUP);
  pinMode(button13,INPUT_PULLUP);
  pinMode(button14,INPUT_PULLUP);
  pinMode(button15,INPUT_PULLUP);
  pinMode(button16,INPUT_PULLUP);
  pinMode(button17,INPUT_PULLUP);
  pinMode(button18,INPUT_PULLUP);
  pinMode(button19,INPUT_PULLUP);
  pinMode(button20,INPUT_PULLUP);
  pinMode(button21,INPUT_PULLUP);
  pinMode(button22,INPUT_PULLUP);
  pinMode(button23,INPUT_PULLUP);
  pinMode(button24,INPUT_PULLUP);

  for(int i=0; i<4; i++)
  {
    pinMode(controlPin[i], OUTPUT);// set pin as output
    digitalWrite(controlPin[i], HIGH); // set initial state as HIGH 
 }

  pinMode(sig1, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig1, HIGH);//lo metto high per i button in pullup

  pinMode(sig2, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig2, HIGH);

  pinMode(sig3, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig3, HIGH);

  pinMode(sig4, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig4, HIGH);

  pinMode(sig5, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig5, HIGH);
    
  pinMode(sig6, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig6, HIGH);
   
  pinMode(sig7, INPUT_PULLUP);// set SIG pin as output
    digitalWrite(sig7, HIGH);      
                            // set SIG sends what should be the output
                            // for low trigger relay it should be LOW
                            // for HIGH trigger high it should be HIGH  
  Serial.begin(9600);
}

 
void loop() {

//PULSANTI VALUE OLD
    static bool button1valueOld = HIGH;
    static bool button2valueOld = HIGH; //forse da fare per ogni pulsante, per il multi press
    static bool button3valueOld = HIGH;
    static bool button4valueOld = HIGH;
    static bool button5valueOld = HIGH;
    static bool button6valueOld = HIGH;
    static bool button7valueOld = HIGH;
    static bool button8valueOld = HIGH;
    static bool button9valueOld = HIGH;
    static bool button10valueOld = HIGH;
    static bool button11valueOld = HIGH;
    static bool button12valueOld = HIGH;
    static bool button13valueOld = HIGH;
    static bool button14valueOld = HIGH;
    static bool button15valueOld = HIGH;
    static bool button16valueOld = HIGH; 
    static bool button17valueOld = HIGH;
    static bool button18valueOld = HIGH;
    static bool button19valueOld = HIGH;
    static bool button20valueOld = HIGH;
    static bool button21valueOld = HIGH;
    static bool button22valueOld = HIGH;
    static bool button23valueOld = HIGH;
    static bool button24valueOld = HIGH;
    
//PULSANTI VALUE NEW  
    bool button1valueNew = digitalRead(button1);
    bool button2valueNew = digitalRead(button2); 
    bool button3valueNew = digitalRead(button3);
    bool button4valueNew = digitalRead(button4);
    bool button5valueNew = digitalRead(button5);
    bool button6valueNew = digitalRead(button6);
    bool button7valueNew = digitalRead(button7);
    bool button8valueNew = digitalRead(button8);
    bool button9valueNew = digitalRead(button9);
    bool button10valueNew = digitalRead(button10);
    bool button11valueNew = digitalRead(button11);
    bool button12valueNew = digitalRead(button12);
    bool button13valueNew = digitalRead(button13);
    bool button14valueNew = digitalRead(button14);
    bool button15valueNew = digitalRead(button15);
    bool button16valueNew = digitalRead(button16);
    bool button17valueNew = digitalRead(button17);
    bool button18valueNew = digitalRead(button18);
    bool button19valueNew = digitalRead(button19);
    bool button20valueNew = digitalRead(button20);
    bool button21valueNew = digitalRead(button21);
    bool button22valueNew = digitalRead(button22);
    bool button23valueNew = digitalRead(button23);
    bool button24valueNew = digitalRead(button24);

//POTENZIOMETRI
    int pot0 = analogRead(A0);
    int analogpot0New = analogRead(A0);
    int pot1 = analogRead(A1);
    int analogpot1New = analogRead(A1);
    int pot2 = analogRead(A2);
    int analogpot2New = analogRead(A2);
    int pot3 = analogRead(A3);
    int analogpot3New = analogRead(A3);
    int pot4 = analogRead(A4);
    int analogpot4New = analogRead(A4);
    int pot5 = analogRead(A5);
    int analogpot5New = analogRead(A5);
    int pot6 = analogRead(A6);
    int analogpot6New = analogRead(A6);
    int pot7 = analogRead(A7);
    int analogpot7New = analogRead(A7);
    int pot8 = analogRead(A8);
    int analogpot8New = analogRead(A8);
    int pot9 = analogRead(A9);
    int analogpot9New = analogRead(A9);
    int pot10 = analogRead(A10);
    int analogpot10New = analogRead(A10);

// reparto lettura high and low dei 16 input multiplexer 1>7 
 for(int i=0; i<16; i++){
        interfaccia(i);
        digitalRead(i);
        digitalRead(sig1);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig1) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux1();
      break;
    case 1:
      Command1Mux1();
      break;
    case 2:
      Command2Mux1();    
      break;
    case 3:
      Command3Mux1();
      break;
    case 4:
      Command4Mux1();
      break;
    case 5:
      Command5Mux1();
      break;
    case 6:
      Command6Mux1();
      break;  
    case 7:
      Command7Mux1();    
      break;
    case 8:
      Command8Mux1();
      break;
    case 9:
      Command9Mux1();
      break;
    case 10:
      Command10Mux1();    
      break;
    case 11:
      Command11Mux1();
      break;
    case 12:
      Command12Mux1();
      break;   
    case 13:
      Command13Mux1();
      break; 
    case 14:
      Command14Mux1(); 
      break;
    case 15:
      Command15Mux1();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
    //FORSE DA FARE UN INTERFACCIA PER OGNI MUX
        interfaccia2(i);
        digitalRead(i);
        digitalRead(sig2);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig2) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux2();
      break;
    case 1:
      Command1Mux2();
      break;
    case 2:
      Command2Mux2();    
      break;
    case 3:
      Command3Mux2();
      break;
    case 4:
      Command4Mux2();
      break;
    case 5:
      Command5Mux2();
      break;
    case 6:
      Command6Mux2();
      break;  
    case 7:
      Command7Mux2();    
      break;
    case 8:
      Command8Mux2();
      break;
    case 9:
      Command9Mux2();
      break;
    case 10:
      Command10Mux2();    
      break;
    case 11:
      Command11Mux2();
      break;
    case 12:
      Command12Mux2();
      break;   
    case 13:
      Command13Mux2();
      break; 
    case 14:
      Command14Mux2(); 
      break;
    case 15:
      Command15Mux2();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
        interfaccia3(i);
        digitalRead(i);
        digitalRead(sig3);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig3) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux3();
      break;
    case 1:
      Command1Mux3();
      break;
    case 2:
      Command2Mux3();    
      break;
    case 3:
      Command3Mux3();
      break;
    case 4:
      Command4Mux3();
      break;
    case 5:
      Command5Mux3();
      break;
    case 6:
      Command6Mux3();
      break;  
    case 7:
      Command7Mux3();    
      break;
    case 8:
      Command8Mux3();
      break;
    case 9:
      Command9Mux3();
      break;
    case 10:
      Command10Mux3();    
      break;
    case 11:
      Command11Mux3();
      break;
    case 12:
      Command12Mux3();
      break;   
    case 13:
      Command13Mux3();
      break; 
    case 14:
      Command14Mux3(); 
      break;
    case 15:
      Command15Mux3();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
        interfaccia4(i);
        digitalRead(i);
        digitalRead(sig4);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig4) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux4();
      break;
    case 1:
      Command1Mux4();
      break;
    case 2:
      Command2Mux4();    
      break;
    case 3:
      Command3Mux4();
      break;
    case 4:
      Command4Mux4();
      break;
    case 5:
      Command5Mux4();
      break;
    case 6:
      Command6Mux4();
      break;  
    case 7:
      Command7Mux4();    
      break;
    case 8:
      Command8Mux4();
      break;
    case 9:
      Command9Mux4();
      break;
    case 10:
      Command10Mux4();    
      break;
    case 11:
      Command11Mux4();
      break;
    case 12:
      Command12Mux4();
      break;   
    case 13:
      Command13Mux4();
      break; 
    case 14:
      Command14Mux4(); 
      break;
    case 15:
      Command15Mux4();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
        interfaccia5(i);
        digitalRead(i);
        digitalRead(sig5);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig5) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux5();
      break;
    case 1:
      Command1Mux5();
      break;
    case 2:
      Command2Mux5();    
      break;
    case 3:
      Command3Mux5();
      break;
    case 4:
      Command4Mux5();
      break;
    case 5:
      Command5Mux5();
      break;
    case 6:
      Command6Mux5();
      break;  
    case 7:
      Command7Mux5();    
      break;
    case 8:
      Command8Mux5();
      break;
    case 9:
      Command9Mux5();
      break;
    case 10:
      Command10Mux5();    
      break;
    case 11:
      Command11Mux5();
      break;
    case 12:
      Command12Mux5();
      break;   
    case 13:
      Command13Mux5();
      break; 
    case 14:
      Command14Mux5(); 
      break;
    case 15:
      Command15Mux5();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
        interfaccia6(i);
        digitalRead(i);
        digitalRead(sig6);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig6) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux6();
      break;
    case 1:
      Command1Mux6();
      break;
    case 2:
      Command2Mux6();    
      break;
    case 3:
      Command3Mux6();
      break;
    case 4:
      Command4Mux6();
      break;
    case 5:
      Command5Mux6();
      break;
    case 6:
      Command6Mux6();
      break;  
    case 7:
      Command7Mux6();    
      break;
    case 8:
      Command8Mux6();
      break;
    case 9:
      Command9Mux6();
      break;
    case 10:
      Command10Mux6();    
      break;
    case 11:
      Command11Mux6();
      break;
    case 12:
      Command12Mux6();
      break;   
    case 13:
      Command13Mux6();
      break; 
    case 14:
      Command14Mux6(); 
      break;
    case 15:
      Command15Mux6();
      break;

    default:
      break;
  }
  }
  }

   for(int i=0; i<16; i++){
        interfaccia7(i);
        digitalRead(i);
        digitalRead(sig7);
                
        //Serial.println(digitalRead(sig1));
        
        //FUNZIONA
        if (digitalRead(sig7) == LOW){ 
        switch (i) {
    case 0:
      Command0Mux7();
      break;
    case 1:
      Command1Mux7();
      break;
    case 2:
      Command2Mux7();    
      break;
    case 3:
      Command3Mux7();
      break;
    case 4:
      Command4Mux7();
      break;
    case 5:
      Command5Mux7();
      break;
    case 6:
      Command6Mux7();
      break;  
    case 7:
      Command7Mux7();    
      break;
    case 8:
      Command8Mux7();
      break;
    case 9:
      Command9Mux7();
      break;
    case 10:
      Command10Mux7();    
      break;
    case 11:
      Command11Mux7();
      break;
    case 12:
      Command12Mux7();
      break;   
    case 13:
      Command13Mux7();
      break; 
    case 14:
      Command14Mux7(); 
      break;
    case 15:
      Command15Mux7();
      break;

    default:
      break;
  }
  }
  }

//pulsanti qui sotto scritti tutti bene    
    if (button1valueNew != button1valueOld){
      if (button1valueNew == LOW){
      //MIDI.sendNoteOn(1, 127, 1);
      Serial.println("Note C On");
      }
      else {
      //MIDI.sendNoteOff(1, 0, 1);
      Serial.println("Note C Off");
      }
      button1valueOld = button1valueNew;
    }
        
    if (button2valueNew != button2valueOld){
      if (button2valueNew == LOW){
      MIDI.sendNoteOn(2, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(2, 0, 1);
      //Serial.println("Note C Off");
      }
      button2valueOld = button2valueNew;
    }

        if (button3valueNew != button3valueOld){
      if (button3valueNew == LOW){
      MIDI.sendNoteOn(3, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(3, 0, 1);
      //Serial.println("Note C Off");
      }
      button3valueOld = button3valueNew;
    }

        if (button4valueNew != button4valueOld){
      if (button4valueNew == LOW){
      MIDI.sendNoteOn(4, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(4, 0, 1);
      //Serial.println("Note C Off");
      }
      button4valueOld = button4valueNew;
    }

        if (button5valueNew != button5valueOld){
      if (button5valueNew == LOW){
      MIDI.sendNoteOn(5, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(5, 0, 1);
      //Serial.println("Note C Off");
      }
      button5valueOld = button5valueNew;
    }

        if (button6valueNew != button6valueOld){
      if (button6valueNew == LOW){
      MIDI.sendNoteOn(6, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(6, 0, 1);
      //Serial.println("Note C Off");
      }
      button6valueOld = button6valueNew;
    }

        if (button7valueNew != button7valueOld){
      if (button7valueNew == LOW){
      MIDI.sendNoteOn(7, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(7, 0, 1);
      //Serial.println("Note C Off");
      }
      button7valueOld = button7valueNew;
    }

        if (button8valueNew != button8valueOld){
      if (button8valueNew == LOW){
      MIDI.sendNoteOn(8, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(8, 0, 1);
      //Serial.println("Note C Off");
      }
      button8valueOld = button8valueNew;
    }

        if (button9valueNew != button9valueOld){
      if (button9valueNew == LOW){
      MIDI.sendNoteOn(9, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(9, 0, 1);
      //Serial.println("Note C Off");
      }
      button9valueOld = button9valueNew;
    }

        if (button10valueNew != button10valueOld){
      if (button10valueNew == LOW){
      MIDI.sendNoteOn(10, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(10, 0, 1);
      //Serial.println("Note C Off");
      }
      button10valueOld = button10valueNew;
    }

        if (button11valueNew != button11valueOld){
      if (button11valueNew == LOW){
      MIDI.sendNoteOn(11, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(11, 0, 1);
      //Serial.println("Note C Off");
      }
      button11valueOld = button11valueNew;
    }

        if (button12valueNew != button12valueOld){
      if (button12valueNew == LOW){
      MIDI.sendNoteOn(12, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(12, 0, 1);
      //Serial.println("Note C Off");
      }
      button12valueOld = button12valueNew;
    }

        if (button13valueNew != button13valueOld){
      if (button13valueNew == LOW){
      MIDI.sendNoteOn(13, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(13, 0, 1);
      //Serial.println("Note C Off");
      }
      button13valueOld = button13valueNew;
    }
    
        if (button14valueNew != button14valueOld){
      if (button14valueNew == LOW){
      MIDI.sendNoteOn(14, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(14, 0, 1);
      //Serial.println("Note C Off");
      }
      button14valueOld = button14valueNew;
    }

        if (button15valueNew != button15valueOld){
      if (button15valueNew == LOW){
      MIDI.sendNoteOn(15, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(15, 0, 1);
      //Serial.println("Note C Off");
      }
      button15valueOld = button15valueNew;
    }

        if (button16valueNew != button16valueOld){
      if (button16valueNew == LOW){
      MIDI.sendNoteOn(16, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(16, 0, 1);
      //Serial.println("Note C Off");
      }
      button16valueOld = button16valueNew;
    }

        if (button17valueNew != button17valueOld){
      if (button17valueNew == LOW){
      MIDI.sendNoteOn(17, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(17, 0, 1);
      //Serial.println("Note C Off");
      }
      button17valueOld = button17valueNew;
    }

        if (button18valueNew != button18valueOld){
      if (button18valueNew == LOW){
      MIDI.sendNoteOn(18, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(18, 0, 1);
      //Serial.println("Note C Off");
      }
      button18valueOld = button18valueNew;
    }

      if (button19valueNew != button19valueOld){
      if (button19valueNew == LOW){
      MIDI.sendNoteOn(19, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(19, 0, 1);
      //Serial.println("Note C Off");
      }
      button19valueOld = button19valueNew;
    }
        if (button20valueNew != button20valueOld){
      if (button20valueNew == LOW){
      MIDI.sendNoteOn(20, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(20, 0, 1);
      //Serial.println("Note C Off");
      }
      button20valueOld = button20valueNew;
    }
        if (button21valueNew != button21valueOld){
      if (button21valueNew == LOW){
      MIDI.sendNoteOn(21, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(21, 0, 1);
      //Serial.println("Note C Off");
      }
      button21valueOld = button21valueNew;
    }
        if (button22valueNew != button22valueOld){
      if (button22valueNew == LOW){
      MIDI.sendNoteOn(22, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(22, 0, 1);
      //Serial.println("Note C Off");
      }
      button22valueOld = button22valueNew;
    }
        if (button23valueNew != button23valueOld){
      if (button23valueNew == LOW){
      MIDI.sendNoteOn(23, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(23, 0, 1);
      //Serial.println("Note C Off");
      }
      button23valueOld = button23valueNew;
    }
        if (button24valueNew != button24valueOld){
      if (button24valueNew == LOW){
      MIDI.sendNoteOn(24, 127, 1);
      //Serial.println("Note C On");
      }
      else {
      MIDI.sendNoteOff(24, 0, 1);
      //Serial.println("Note C Off");
      }
      button24valueOld = button24valueNew;
    }
//pulsanti qui sopra scritti tutti bene



//POTENZIOMETRI

//FUNZIONA anche se non precisissimo allo 0 ed al 1023,
    //colpa dei pottenziometri a parer mio, da ricontrollare quando
    //arrivano i fader dalla china gang
    //UPDATE DA RIVEDERE CHE LI LEGGE QUANDO PREMO I PULSANTI DEL MUX A CASO

    if (analogpot0New - analogpot0Old >= 20 || analogpot0Old - analogpot0New >= 20) {
      analogpot0Old = analogpot0New;
      analogpot0New = (map(analogpot0New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot0New = (constrain(analogpot0New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot0CC, analogpot0New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}

    if (analogpot1New - analogpot1Old >= 20 || analogpot1Old - analogpot1New >= 20) {
      analogpot1Old = analogpot1New;
      analogpot1New = (map(analogpot1New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot1New = (constrain(analogpot1New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot1CC, analogpot1New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot2New - analogpot2Old >= 20 || analogpot2Old - analogpot2New >= 20) {
      analogpot2Old = analogpot2New;
      analogpot2New = (map(analogpot2New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot2New = (constrain(analogpot2New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot2CC, analogpot2New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot3New - analogpot3Old >= 20 || analogpot3Old - analogpot3New >= 20) {
      analogpot3Old = analogpot3New;
      analogpot3New = (map(analogpot3New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot3New = (constrain(analogpot3New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot3CC, analogpot3New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot4New - analogpot4Old >= 20 || analogpot4Old - analogpot4New >= 20) {
      analogpot4Old = analogpot4New;
      analogpot4New = (map(analogpot4New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot4New = (constrain(analogpot4New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot4CC, analogpot4New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot5New - analogpot5Old >= 20 || analogpot5Old - analogpot5New >= 20) {
      analogpot5Old = analogpot5New;
      analogpot5New = (map(analogpot5New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot5New = (constrain(analogpot5New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot5CC, analogpot5New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot6New - analogpot6Old >= 20 || analogpot6Old - analogpot6New >= 20) {
      analogpot6Old = analogpot6New;
      analogpot6New = (map(analogpot6New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot6New = (constrain(analogpot6New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot6CC, analogpot6New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot7New - analogpot7Old >= 20 || analogpot7Old - analogpot7New >= 20) {
      analogpot7Old = analogpot7New;
      analogpot7New = (map(analogpot7New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot7New = (constrain(analogpot7New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot7CC, analogpot7New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot8New - analogpot8Old >= 20 || analogpot8Old - analogpot8New >= 20) {
      analogpot8Old = analogpot8New;
      analogpot8New = (map(analogpot8New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot8New = (constrain(analogpot8New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot8CC, analogpot8New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot9New - analogpot9Old >= 20 || analogpot9Old - analogpot9New >= 20) {
      analogpot9Old = analogpot9New;
      analogpot9New = (map(analogpot9New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot9New = (constrain(analogpot9New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot9CC, analogpot9New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}
    if (analogpot10New - analogpot10Old >= 20 || analogpot10Old - analogpot10New >= 20) {
      analogpot10Old = analogpot10New;
      analogpot10New = (map(analogpot10New, 1023, 0, 0, 120  )); //il 127 era 120
      analogpot10New = (constrain(analogpot10New, 0, 120)); //tolto perche non mi serve il constrain mi basta la mappatura 
      MIDI.sendControlChange(analogpot10CC, analogpot10New, 3);

    /*
      Serial.print ("pot: ");
      Serial.println(pot1);
      Serial.print("potread: ");
      Serial.println(analogpot1New); 
    */
}




}//FINE VOID LOOP



void interfaccia (int canale) {
    digitalWrite(controlPin[0], multiplexer[canale][0]);
    digitalWrite(controlPin[1], multiplexer[canale][1]);
    digitalWrite(controlPin[2], multiplexer[canale][2]);
    digitalWrite(controlPin[3], multiplexer[canale][3]);
}
void interfaccia2 (int canale) {
    digitalWrite(controlPin[0], multiplexer2[canale][0]);
    digitalWrite(controlPin[1], multiplexer2[canale][1]);
    digitalWrite(controlPin[2], multiplexer2[canale][2]);
    digitalWrite(controlPin[3], multiplexer2[canale][3]);
}
void interfaccia3 (int canale) {
    digitalWrite(controlPin[0], multiplexer3[canale][0]);
    digitalWrite(controlPin[1], multiplexer3[canale][1]);
    digitalWrite(controlPin[2], multiplexer3[canale][2]);
    digitalWrite(controlPin[3], multiplexer3[canale][3]);
}
void interfaccia4 (int canale) {
    digitalWrite(controlPin[0], multiplexer4[canale][0]);
    digitalWrite(controlPin[1], multiplexer4[canale][1]);
    digitalWrite(controlPin[2], multiplexer4[canale][2]);
    digitalWrite(controlPin[3], multiplexer4[canale][3]);
}
void interfaccia5 (int canale) {
    digitalWrite(controlPin[0], multiplexer5[canale][0]);
    digitalWrite(controlPin[1], multiplexer5[canale][1]);
    digitalWrite(controlPin[2], multiplexer5[canale][2]);
    digitalWrite(controlPin[3], multiplexer5[canale][3]);
}
void interfaccia6 (int canale) {
    digitalWrite(controlPin[0], multiplexer6[canale][0]);
    digitalWrite(controlPin[1], multiplexer6[canale][1]);
    digitalWrite(controlPin[2], multiplexer6[canale][2]);
    digitalWrite(controlPin[3], multiplexer6[canale][3]);
}
void interfaccia7 (int canale) {
    digitalWrite(controlPin[0], multiplexer7[canale][0]);
    digitalWrite(controlPin[1], multiplexer7[canale][1]);
    digitalWrite(controlPin[2], multiplexer7[canale][2]);
    digitalWrite(controlPin[3], multiplexer7[canale][3]);
}


void Command0Mux1() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig1) == LOW){
             MIDI.sendNoteOn(32, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            MIDI.sendNoteOff(32, 0, 1);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux1() {
  Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(33, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(33, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux1() {
  Serial.println("Command 3 funziona?");
  
if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(34, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(34, 0, 1);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux1() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(35, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(35, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux1() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(36, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(36, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux1() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(37, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(37, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux1() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(38, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(38, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux1() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(39, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(39, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux1() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(40, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(40, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux1() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(41, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(41, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux1() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(42, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(42, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux1() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(43, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(43, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux1() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig1) == LOW){
             //MIDI.sendNoteOn(44, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(44, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux1() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(45, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(45, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux1() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(46, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
           // MIDI.sendNoteOff(46, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux1() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig1) == LOW){
            // MIDI.sendNoteOn(47, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig1) != LOW){ 
            //MIDI.sendNoteOff(47, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }



void Command0Mux2() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(48, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
           // MIDI.sendNoteOff(48, 0, 1);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux2() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig2) == LOW){
            // MIDI.sendNoteOn(49, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(49, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux2() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(50, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
           // MIDI.sendNoteOff(50, 0, 1);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux2() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(51, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(51, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux2() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(52, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
           // MIDI.sendNoteOff(52, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux2() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(53, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(53, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux2() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(54, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
           // MIDI.sendNoteOff(54, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux2() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig2) == LOW){
            // MIDI.sendNoteOn(55, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(55, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux2() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(56, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(56, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux2() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(57, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(57, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux2() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig2) == LOW){
            // MIDI.sendNoteOn(58, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(58, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux2() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(59, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(59, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux2() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(60, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
           // MIDI.sendNoteOff(60, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux2() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(61, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(61, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux2() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig2) == LOW){
             //MIDI.sendNoteOn(62, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(62, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux2() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig2) == LOW){
            // MIDI.sendNoteOn(63, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig2) != LOW){ 
            //MIDI.sendNoteOff(63, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }




void Command0Mux3() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(64, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(64, 0, 1);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux3() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(65, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(65, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux3() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(66, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(66, 0, 1);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux3() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(67, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(67, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux3() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(68, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(68, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux3() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(69, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(69, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux3() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(70, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(70, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux3() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(71, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(71, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux3() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(72, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(72, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux3() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(73, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(73, 0, 1);          
            Serial.println("Note3 E Off");
      }
      }   
      }


void Command10Mux3() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(74, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(74, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux3() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(75, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(75, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux3() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(76, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(76, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux3() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(77, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(77, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux3() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(78, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(78, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux3() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig3) == LOW){
             MIDI.sendNoteOn(79, 127, 1);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig3) != LOW){ 
            MIDI.sendNoteOff(79, 0, 1);          
            Serial.println("Note E Off");
      }
      }   
      }



void Command0Mux4() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(1, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(1, 0, 2);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux4() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(2, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(2, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux4() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(3, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(3, 0, 2);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux4() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(4, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(4, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux4() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(5, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(5, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux4() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(6, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(6, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux4() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(7, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(7, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux4() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(8, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(8, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux4() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(9, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(9, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux4() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(10, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(10, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux4() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(11, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(11, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux4() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(12, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(12, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux4() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(13, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(13, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux4() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(14, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(14, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux4() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(15, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(15, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux4() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig4) == LOW){
             MIDI.sendNoteOn(16, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig4) != LOW){ 
            MIDI.sendNoteOff(16, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }



void Command0Mux5() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(17, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(17, 0, 2);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux5() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(18, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(18, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux5() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(19, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(19, 0, 2);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux5() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(20, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(20, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux5() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(21, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(21, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux5() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(22, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(22, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux5() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(23, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(23, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux5() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(24, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(24, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux5() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(25, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(25, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux5() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(26, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(26, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux5() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(27, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(27, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux5() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(28, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(28, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux5() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(29, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(29, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux5() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(30, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(30, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux5() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(31, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(31, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux5() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig5) == LOW){
             MIDI.sendNoteOn(32, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig5) != LOW){ 
            MIDI.sendNoteOff(32, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      } 



void Command0Mux6() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(33, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(33, 0, 2);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux6() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(34, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(34, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux6() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(35, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(35, 0, 2);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux6() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(36, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(36, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux6() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(37, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(37, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux6() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(38, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(38, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux6() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(39, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(39, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux6() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(40, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(40, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux6() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(41, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(41, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux6() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(42, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(42, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux6() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(43, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(43, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux6() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(44, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(44, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux6() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(45, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(45, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux6() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(46, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(46, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux6() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(47, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(47, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux6() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig6) == LOW){
             MIDI.sendNoteOn(48, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig6) != LOW){ 
            MIDI.sendNoteOff(48, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }  



void Command0Mux7() {
  //Serial.println("Command 1 funziona?");
  
if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(49, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(49, 0, 2);          
            Serial.println("Note E Off");
      }
      }
      }   

//Da sistemare 
void Command1Mux7() {
  //Serial.println("Command 2 funziona?");
  
      if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(50, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(50, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

     


void Command2Mux7() {
  //Serial.println("Command 3 funziona?");
  
if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(51, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(51, 0, 2);          
            Serial.println("Note E Off");
      }
      } 
      }  
      
void Command3Mux7() {
 // Serial.println("Command 4 funziona?");
 
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(52, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(52, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command4Mux7() {
  //Serial.println("Command 5 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(53, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(53, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command5Mux7() {
  //Serial.println("Command 6 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(54, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(54, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command6Mux7() {
  //Serial.println("Command 7 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(55, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(55, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command7Mux7() {
  //Serial.println("Command 8 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(56, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(56, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command8Mux7() {
  //Serial.println("Command 9 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(57, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(57, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command9Mux7() {
  //Serial.println("Command 10 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(58, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(58, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command10Mux7() {
  //Serial.println("Command 11 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(59, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(59, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command11Mux7() {
  //Serial.println("Command 12 funziona?");
  
if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(60, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(60, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command12Mux7() {
  //Serial.println("Command 13 funziona?");
  
if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(61, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(61, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }

void Command13Mux7() {
 // Serial.println("Command 14 funziona?");
 
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(62, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(62, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command14Mux7() {
  //Serial.println("Command 15 funziona?");

 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(63, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(63, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }


void Command15Mux7() {
  //Serial.println("Command 16 funziona?");
  
 if (digitalRead(sig7) == LOW){
             MIDI.sendNoteOn(64, 127, 2);                        
             Serial.println("Note E On");
             
        if (digitalRead(sig7) != LOW){ 
            MIDI.sendNoteOff(64, 0, 2);          
            Serial.println("Note E Off");
      }
      }   
      }               
1 Like

Questi sono i collegamenti, scusate.


Buongiorno e benvenuto, :slight_smile:
essendo il tuo primo post, nel rispetto del regolamento della sezione Italiana del forum (… punto 13, primo capoverso), ti chiedo cortesemente di presentarti IN QUESTO THREAD (spiegando bene quali conoscenze hai di elettronica e di programmazione ... possibilmente evitando di scrivere solo una riga di saluto) e di leggere con molta attenzione tutto il succitato REGOLAMENTO ... Grazie. :slight_smile:

Guglielmo

P.S.: Ti ricordo che, purtroppo, fino a quando non sarà fatta la presentazione nell’apposito thread, nel rispetto del suddetto regolamento nessuno ti risponderà, quindi ti consiglio di farla al più presto. :wink: