| Author |
Message |
MusicMan11712

Joined: Aug 08, 2009 Posts: 556 Location: Upstate New York USA
Audio files: 151
|
Posted: Tue Jul 03, 2012 6:45 pm Post subject:
Testing MIDI IN |
 |
|
While exploring my arduino last summer, I wrote a little sketch to test whether or not I was correctly receiving midi in by echoing that data to the console in the arduino's programming environment. I haven't tested it this year, but it should help others do the same.
I used the Arduino Mega 2560, which has 4 serial I/O ports. Also, the pins might be different from other arduinos.
| Code: |
/*
MIDI IN test
This sketch is an attempt to read midi in and display it.
This is one step in the process of creating an arduino-based midi router/processor/arpeggiator.
started 05 Aug 2011
modified
by Dr. Steve [aka MusicMan11712]
*/
// MIDI IN Buffer [as an array]
int MidiDataBuffer [256];
// Buffer Pointers [as indexes]
unsigned char WritePointer = 0;
unsigned char ReadPointer = 0;
byte WP = 0;
byte RP = 0;
// Incoming Data
int IncomingByte = 0; // incoming serial byte
// SETUP
void setup() {
// Set MIDI baud rate:
Serial1.begin(31250);
Serial.begin(9600);
// Clear MidiDataBuffer and reset write/read pointers
for (int n=0; n<256> 0) {
// get incoming byte:
IncomingByte = Serial1.read();
Serial.println (IncomingByte,HEX);
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.println("0,0,0"); // send an initial string
delay(300);
}
}
|
|
|
|
Back to top
|
|
 |
elmegil

Joined: Mar 20, 2012 Posts: 989 Location: Chicago
Audio files: 14
|
Posted: Tue Jul 03, 2012 9:51 pm Post subject:
|
 |
|
The Mega (or some model with multiple serial ports) is really your best bet here for doing MIDI development. I did a lot of work with an uno equivalent (started out as the Mintduino breadboard kit, and ended up soldered into a small protoboard), and i beat my head on MIDI stuff until I got the Mega.
Some of my experiences got written up here:
http://electro-music.com/forum/topic-52722.html |
|
|
Back to top
|
|
 |
MusicMan11712

Joined: Aug 08, 2009 Posts: 556 Location: Upstate New York USA
Audio files: 151
|
Posted: Wed Jul 04, 2012 5:23 am Post subject:
|
 |
|
Thanks for chiming in on this and for posting the link to the thread with your comments--useful info there. I realized after I posted the midi in test code that it wouldn't work on a single UART Arduino since midi needs one serial connection and communication with the serial monitor needs another. (I chose the Mega 2560 specifically because it had 4 UARTs.)
Like you, for midi I/O I used an old joystick to midi cable. I didn't take it apart, though.
Steve |
|
|
Back to top
|
|
 |
|