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 : https://i.sstatic.net/ppLJn.jpg.
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.
serial.print(...);
) into yourMyHandleNoteOn()
function, you'll be able to tell whether you're detecting too many keys, or lighting too many LEDs.