Using : Arduino UNO with USB Host Shield, A MIDI device sends MIDI through USB.
Here is the function I'm using to receive MIDI from USB and sends it to serial : (USB Host Shield 2.0 Library)
void MIDI_poll()
{
uint8_t outBuf[ 3 ];
uint8_t size;
do {
if ( (size = Midi.RecvData(outBuf)) > 0 ) {
//MIDI Output
Serial.write(outBuf, size);
}
} while (size > 0);
}
"uint8_t RecvData(uint8_t *outBuf)"
Receive MIDI message (3 bytes)
return value is MIDI message length(0-3)
And I used MIDI Library, so my void loop looks like this:
void loop()
{
Usb.Task();
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
}
MIDI.read();
}
But I can't get MIDI data read from the serial.
What should I do? Is it code problem or my MIDI device not working correctly?