   //Set all the buttons of the pad to off.
   for (i = 0; i < padColumns*padRows; i++){
     padState[i] = 0;
+    lastPadState[i] = 0;
   }
   //Set all the buttons of the pad to off.
   for (i = 0; i < buttonRows*buttonColumns; i++){
     buttonState[i] = 0;
   }
 
-  for (i = 0; i < (sizeof(muxEn) / sizeof(byte)) * 8); i++){
-    analogvalue[i] = 0 ;
+  for (i = 0; i < (sizeof(muxEn) / sizeof(byte)) * 8; i++){
+    analogValue[i] = 0 ;
   }
 
   readAnalog(); //Read the initial value of the knobs

    trans = -2;
  }
  for (byte i = 0; i <  sizeof(keyMidi) / sizeof(byte); i++) {
    keyMidi[i] = keyMidiCons[i] + trans * 12;
  }
}


static const byte noteOFF = B10000000;
static const byte control = B10110000;
static const byte pitchBend = B11100000;
static const byte padMidi = B00000000; //Pad first note.
static const byte buttonMidi = B00010000; //Controll general first code.
static const byte analogMidi =B00110000; //Controll general first code.
// MIDI codes taken from http://nickfever.com/music/midi-cc-list
static const byte MIDI_CC_MODULATION = B00000001;
