   }
 }
 
-
-/**
-   Method to send the midi messega.
-   @param pCmd the midi command code.
-   @param pPitch the pitch of the note.
-   @param pVelocity of the note.
-   @return void
-*/
-void midiSend(byte pCmd, byte pPitch, byte pVelocity) {
+/**
+    Method to send a control message with analog values.
+    @param pChannel the channel to send the message.
+    @param pControl the note to turn on.
+    @param pValue the value to send.
+*/
+void controlMessage(byte pChannel, byte pControl, byte pValue){
+  pChannel += control-1;
+  midiSend(pChannel,pControl, pValue);
+}
+
+/**
+    Method to send a note on message.  
+    @param pChannel the channel to send the noteon.
+    @param pPitch the note to turn on.
+    @param pVelocity the velocity of the note.
+ */
+void noteOn(byte pChannel, byte pPitch, byte pVelocity){
+  pChannel += noteON-1;
+  midiSend(pChannel, pPitch, pVelocity);
+}
+
+/**
+    Method to send a note off message.
+    @param pChannel the channel to send the noteoff.
+    @param pPitch the note to turn off.
+ */
+void noteOff(byte pChannel, byte pPitch){
+  pChannel += noteOFF-1;
+  midiSend(pChannel, pPitch, 0);
+}
+
+/**
+   Method to send the midi message.
+   @param statusByte the status midi command.
+   @param dataByte1 the first data byte.
+   @param dataByte2 the second data byte.
+   @return void
+*/
+void midiSend(byte statusByte, byte dataByte1, byte dataByte2) {
   if (!debug) {
-    Serial.write(pCmd);
-    Serial.write(pPitch);
-    Serial.write(pVelocity);
+    Serial.write(statusByte);
+    Serial.write(dataByte1);
+    Serial.write(dataByte2);
   } else {
     Serial.println("Begin Message.");
-    Serial.println(pCmd, BIN);
-    Serial.println(pPitch, BIN);
-    Serial.println(pVelocity, BIN);
+    Serial.println(statusByte, BIN);
+    Serial.println(dataByte1, BIN);
+    Serial.println(dataByte2, BIN);
     Serial.println("End Message.");
   }
 }

        tempVelocity = 127;
      }
    }
    /*Serial.println("Velocity 2");
      Serial.print(tempVelocity, DEC);
      Serial.print(" ");
      Serial.println("Time 2");
      Serial.println(abs(millis()-noteTime[pPos]), DEC);
      Serial.println("Pos 2");
      Serial.println(pPos, DEC);
      delay(10);*/
    return tempVelocity;
  }
}

                                       B01000000, B01000000, B01000001, B01000001, B01000010, B01000010, B00111101, B00111101, B00111110, B00111110, B00111111, B00111111,
                                       0, 0, 0, 0, B00111100, B00111100, 0, 0, 0, 0, 0, 0
                                      };
byte blank = B00000000;//To send blank to the register.
byte noteON = B10010000;
byte noteOFF = B10000000;
byte control = B10110000;
byte pitchBend = B11100001;
static const short sensitivity = 1000;
static const short keyboardChannel = 1;
static const short drumsChannel = 2;
static bool debug = false;

//Variables
static bool sValue[] = {0, 0, 0}; // S0, S1, S2 values
