Need Help with UNO and Receiving MIDI IN

Started by steve73, April 23, 2016, 03:59:31 PM

Previous topic - Next topic

steve73

I have an Arduino UNO and an Olimex Shield-MIDI. All I'm looking to do at this point is make an LED light up when MIDI is received.

I'm sending a MIDI clock signal to the MIDI shield and running the MIDI THRU to another device. I can adjust the tempo on the sending device and the other device responds, which tells me the sending device is sending a signal, and the OLIMEX THRU port is working. The MIDI IN must be working too.

So, how can I detect that MIDI is being received on the OLIMEX shield?

I have this sketch, but it doesn't blink the RED LED. The RED LED has been testing and works outside of the loop.

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

int ledPinRed = 06;                       // LED connected to digital pin 6
int ledPinGrn = 07;                        // LED connected to digital pin 7

void setup()
{
    MIDI.begin(MIDI_CHANNEL_OMNI);         // Launch MIDI, listen all channels
}


void loop()
{
               //*************** BLINK GREEN LED SO I KNOW THE SKETCH IS RUNNING ***************//
      digitalWrite(ledPinGrn, HIGH);      // sets the GREEN LED on
      delay(1000);                        // waits for a second;
      digitalWrite(ledPinGrn, LOW);       //set the GREEN LED off
      delay(1000);                        // waits for a second;


             //*************** READ MIDI IN AND BLINK RED LED IF SIGNAL RECIEVED - THIS IS NOT WORKING ***************//
    if (MIDI.read())                      // Is there a MIDI message incoming ?
    {
      digitalWrite(ledPinRed, HIGH);     // sets the RED LED on
      delay(500);                        // waits for a second;
      digitalWrite(ledPinRed, LOW);       //set the RED LED off
    }
}


any assistance would be greatly appreciated. Thank you.

steve73

update: Gettin closer. The shield uses the same interrupts as the USB port, so while this is annoying, it still works, just have to switch the jumper on the board after uploading.

So now I can read the serial data stream on the MIDI IN port, but I don't know how to filter out everything but clock messages or interpret it correctly to flash an LED in time with the clock signal.