Hi everybody,
I have been trying to receive MIDI messages using my Arduino Uno and the circuit shown here...
http://arduino.cc/forum/index.php/topic,22447.0.html
I have built the MIDI interface on a breadboard and am receiving signals from a keyboard.
Instead of connecting LED's like in the above post I am trying to control an 8x8 LED matrix. So far the MIDI input works however the response is slow and unreliable. If I play notes slowly the LED's will turn on and off as they are suppose to however if you play a note quickly the noteOff messages are missed. More specifically, striking a key quickly turns the LED on but not off.
Similarly, playing runs of notes quickly produces unreliable results with most of the messages on and off being missed.
On the other hand, if I play 4 of 5 notes at the same time the appropriate LED's turn on and off as expected. As long as you play slowly (keep each key pressed for at least a full second) the lights turn on and off.
I have modified the the code to use the Arduino Midi library instead of listening to the serial port like in the original post. This works slightly better however it still seems to be lagging behind.
if (MIDI.read()) {
if (MIDI.getType() == NoteOn) {
// get note value
byte dat1 = MIDI.getData1();
// get velocity (though I'm not using it)
byte dat2 = MIDI.getData2();
// map MIDI note value to 8x8 array
int row = dat1/8;
int col = dat1%8;
// my keyboard sends noteOn with 0 velocity instead of noteOff messages
if (dat2 > 10) {
displayGrid[row][col] = 1;
}
else {
displayGrid[row][col] = 0;
}
}
refreshDisplay();
The semantics on controlling the lights are not really important here. The 8x8 array is controlled by a 8x8 array on ints in memory. 0 for off, 1 for on. I simply change these values and refresh the display. This code comes from an old project and works fine.
Is the issues here the MIDI interface and am I better off building the one prescribed here.
http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html
Thanks heaps