user32169: I am trying to reverse engineer the project from this video: https://youtu.be/zc1zbwheyE0?t=50s.  
From the video a visible 10 wires are going from the LEDs to the Arduino mega, i am assuming that they are wired in a 5x5 matrix (5 rows, 5 columns) given that there are 25 keys on the Midi controller so there most be 25 LEDs.
I reconstructed the project the best a could from observing the video, but my issue is when i press 3 keys 5 LEDs light up unlike in the original video where 3 keys are pressed and 3 LEDs light up(as seen @ 0:50 of the video).
This is the issue i am having : http://imgur.com/a/9SOEJ.
I am thinking the issue is related to how i have my LEDs wired, but my LEDs are wired exactly the same as in the video. isn't it ? is there something i might have missed? How is the project in the video able to light up 3 LEDs without having an issue with extra LEDs lighting up in their matrix? how can i fix my circuit to replicate the video?  
Here is some of my coed for turning on an LED when a key is pressed:
<include MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

byte anodes[5] = {30, 32, 34, 36,38};

byte cathodes[5] = {31, 33, 35, 37,39};

byte data1 = 0;

void setPinTo5V(byte pin) //set a pin given to this function to a 5V voltage source

{
    pinMode(pin, OUTPUT);
    digitalWrite(pin, HIGH);
}

void setPinToGND(byte pin) //set a pin given to this function to a GROUND (GND pin)
{
    pinMode(pin, OUTPUT);
    digitalWrite(pin, LOW);
}

void loop() {
    MIDI.read();
}

void MyHandleNoteOn(byte channel, byte pitch, byte velocity)
{
    data1 = MIDI.getData1();

    if (data1==48){//C3
        setPinTo5V(anodes[0]);//set pin 30 to 5V
        setPinToGND(cathodes[0]);//set pin 31 to GND

        delay(1); //do nothing for 1 ms
    } //this is done for all 25 keys

}

any help would be appreciated Thanks.

user32169: This was what i was able to come up with, once a notes is press the blink function turns the LED on and off really fast. i am now have trouble getting the led to turn off once the notes is being pressed am not sure if the code is exiting from the while loop.
include 
MIDI_CREATE_DEFAULT_INSTANCE();
define LedR 3   //
define LedC 4 //pin for each led
byte data1 = 0;
unsigned long previousMillisR[2]; //[x] = number of leds
unsigned long previousMillisC[2]; //[x] = number of leds
int Status [25];
void setup() { 
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleNoteOn(MyHandleNoteOn);
MIDI.setHandleNoteOff(MyHandleNoteOff);
pinMode(LedR, OUTPUT);   
pinMode(LedC, OUTPUT);  
}
void loop() {
MIDI.read();
//BlinkLedR(LedR,2000, 0);   //BlinkLed( which led, interval, one of the 
stored prevMillis
//BlinkLedC(LedC, 10, 0);  //last parameters must be different for each 
led
}
void BlinkLedR (int led, int interval, int array){   
//(long) can be omitted if you dont plan to blink led for very long time I think
if (((long)millis() - previousMillisR[array]) >= interval){ 
previousMillisR[array]= millis(); //stores the millis value in the 

selected array
digitalWrite(led, !digitalRead(led)); //changes led state
}
}
void BlinkLedC (int led, int interval, int array){   
//(long) can be omitted if you dont plan to blink led for very long 
time I think
if (((long)millis() - previousMillisC[array]) >= interval){ 
previousMillisC[array]= millis(); //stores the millis value in the 

selected array
digitalWrite(led, !digitalRead(led)); //changes led state

}
}
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 
data1 = MIDI.getData1();
if (data1==48){//C3
Status[0]=1;
while(Status[0]==1) {
BlinkLedR(LedR, 10, 0);   //BlinkLed( which led, interval, one of the 
stored prevMillis
BlinkLedC(LedC, 1, 0);  //last parameters must be different for each led
if (Status==!1){
break;
}
}
}
}
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 
data1 = MIDI.getData1();
if (data1==48){//C3
Status[0]=0;
}
}

32169: <p>I am trying to reverse engineer the project from this video: <a href="https://youtu.be/zc1zbwheyE0?t=50s" rel="nofollow noreferrer">https://youtu.be/zc1zbwheyE0?t=50s</a>.  </p>

<p>From the video a visible 10 wires are going from the LEDs to the Arduino mega, i am assuming that they are wired in a 5x5 matrix (5 rows, 5 columns) given that there are 25 keys on the Midi controller so there most be 25 LEDs.<br>
I reconstructed the project the best a could from observing the video, but my issue is when i press 3 keys 5 LEDs light up unlike in the original video where 3 keys are pressed and 3 LEDs light up(as seen @ 0:50 of the video).<br>
This is the issue i am having : <a href="https://imgur.com/a/9SOEJ" rel="nofollow noreferrer">http://imgur.com/a/9SOEJ</a>.<br>
I am thinking the issue is related to how i have my LEDs wired, but my LEDs are wired exactly the same as in the video. isn't it ? is there something i might have missed? How is the project in the video able to light up 3 LEDs without having an issue with extra LEDs lighting up in their matrix? how can i fix my circuit to replicate the video?  </p>

<p>Here is some of my coed for turning on an LED when a key is pressed:</p>

<pre><code>&lt;include MIDI.h&gt;

MIDI_CREATE_DEFAULT_INSTANCE();

byte anodes[5] = {30, 32, 34, 36,38};

byte cathodes[5] = {31, 33, 35, 37,39};

byte data1 = 0;

void setPinTo5V(byte pin) //set a pin given to this function to a 5V voltage source

{
    pinMode(pin, OUTPUT);
    digitalWrite(pin, HIGH);
}

void setPinToGND(byte pin) //set a pin given to this function to a GROUND (GND pin)
{
    pinMode(pin, OUTPUT);
    digitalWrite(pin, LOW);
}

void loop() {
    MIDI.read();
}

void MyHandleNoteOn(byte channel, byte pitch, byte velocity)
{
    data1 = MIDI.getData1();

    if (data1==48){//C3
        setPinTo5V(anodes[0]);//set pin 30 to 5V
        setPinToGND(cathodes[0]);//set pin 31 to GND

        delay(1); //do nothing for 1 ms
    } //this is done for all 25 keys

}
</code></pre>

<p>any help would be appreciated Thanks.</p>
 32169: <p>This was what i was able to come up with, once a notes is press the blink function turns the LED on and off really fast. i am now have trouble getting the led to turn off once the notes is being pressed am not sure if the code is exiting from the while loop.</p>

<h1>include </h1>

<p>MIDI_CREATE_DEFAULT_INSTANCE();</p>

<h1>define LedR 3   //</h1>

<h1>define LedC 4 //pin for each led</h1>

<p>byte data1 = 0;</p>

<p>unsigned long previousMillisR[2]; //[x] = number of leds</p>

<p>unsigned long previousMillisC[2]; //[x] = number of leds</p>

<p>int Status [25];</p>

<p>void setup() { </p>

<p>MIDI.begin(MIDI_CHANNEL_OMNI);</p>

<p>MIDI.setHandleNoteOn(MyHandleNoteOn);</p>

<p>MIDI.setHandleNoteOff(MyHandleNoteOff);</p>

<p>pinMode(LedR, OUTPUT);   </p>

<p>pinMode(LedC, OUTPUT);  </p>

<p>}</p>

<p>void loop() {</p>

<p>MIDI.read();</p>

<p>//BlinkLedR(LedR,2000, 0);   //BlinkLed( which led, interval, one of the 
stored prevMillis</p>

<p>//BlinkLedC(LedC, 10, 0);  //last parameters must be different for each 
led</p>

<p>}</p>

<p>void BlinkLedR (int led, int interval, int array){   </p>

<p>//(long) can be omitted if you dont plan to blink led for very long time I think</p>

<p>if (((long)millis() - previousMillisR[array]) >= interval){ </p>

<pre><code>previousMillisR[array]= millis(); //stores the millis value in the 
</code></pre>

<p>selected array</p>

<p>digitalWrite(led, !digitalRead(led)); //changes led state</p>

<p>}</p>

<p>}</p>

<p>void BlinkLedC (int led, int interval, int array){   </p>

<p>//(long) can be omitted if you dont plan to blink led for very long 
time I think</p>

<p>if (((long)millis() - previousMillisC[array]) >= interval){ </p>

<pre><code>previousMillisC[array]= millis(); //stores the millis value in the 
</code></pre>

<p>selected array</p>

<pre><code>digitalWrite(led, !digitalRead(led)); //changes led state
</code></pre>

<p>}</p>

<p>}</p>

<p>void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { </p>

<p>data1 = MIDI.getData1();</p>

<p>if (data1==48){//C3</p>

<p>Status[0]=1;</p>

<p>while(Status[0]==1) {</p>

<p>BlinkLedR(LedR, 10, 0);   //BlinkLed( which led, interval, one of the </p>

<p>stored prevMillis</p>

<p>BlinkLedC(LedC, 1, 0);  //last parameters must be different for each led</p>

<p>if (Status==!1){</p>

<p>break;</p>

<p>}</p>

<p>}</p>

<p>}</p>

<p>}</p>

<p>void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { </p>

<p>data1 = MIDI.getData1();</p>

<p>if (data1==48){//C3</p>

<p>Status[0]=0;</p>

<p>}</p>

<p>}</p>
