I ran into exactly the same scenario and found a workaround.
I had kuk's MIDI solution wired on a second hand Yamaha keyboard I bought, and was only able to receive a 144 note on signal every 4 or so seconds.
I was pretty sure it had to be the same reason, as the original poster also mentioned a Yamaha PSR series keyboard.
It turns out that Yamaha does kind of ignore MIDI standards. The signals I received on playing "C D E" for example were:
144
20 80 20 0
22 80 22 0
24 80 24 0
So the information about all the notes is being passed through, just not always starting with a 144 note on signal. No idea why.
But every noted is being closed with a velocity of 0, which can be used to detect which notes have been played:
Code:
void loop () {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte >= 36 && incomingByte <= 96) { // note range is between 36 and 96
prevNote = incomingByte;
}
else if (incomingByte == 0) {
blink();
output += prevNote;
output += "-";
}
}
}
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte >= 36 && incomingByte <= 96) { // note range is between 36 and 96
prevNote = incomingByte;
}
else if (incomingByte == 0) {
blink();
output += prevNote;
output += "-";
}
}
}
So my code ignores the 144 signals, but every time it detects a 0 signal, it adds the previously read byte to the output, as that one represents the note that has just been hit. This doesn't yet take velocity into account, a slightly more complex code is needed for that, but for me this was sufficient.
Hope this helps!