I put together a MIDI-in device according to the schematic on
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258 on the old forum (and I read every post on said thread).
However, when I connect my midi keyboard and play on it, my arduino's output puzzles me (output and code below). For one thing, I don't get unique output from all keys. Can anyone offer insight as to why I might be encountering this difficulty?
Keying on, then off, for the top 12 notes on my MIDI keyboard outputs the following:
243 186 2 0
243 250 0
19 117 2 0
19 245 0
51 117 2 0
51 245 0
83 117 2 0
83 245 0
115 117 2 0
115 245 0
147 117 2 0
147 245 0
179 117 2 0
179 245 0
211 117 2 0
211 245 0
243 117 2 0
243 245 0
19 117 2 0
19 245 0
51 117 2 0
51 245 0
83 117 2 0
83 245 0
This is all sorts of puzzling: after 8 semitones, the first byte repeats, and the following bytes remain constant for a while, so that two distinct notes may yield exact matches. For instance, line 3 (3rd B above middle C) matches line 19 (3rd D# above middle C).
Here's my code (implemented on an MEGA 2560:
void setup() {
mySerial.begin(31250); // read midi-in
Serial.begin(9600); // output to monitor on pc
}
void loop() {
if (mySerial.available()) {
while (mySerial.available()) {
byte in = mySerial.read(); Serial.print(in); Serial.print(" \t ");
}
Serial.println();
}
}
Do please help.