Help with MIDI sysex

I’ve been experimenting with sending MIDI messages to the RockBand Pro Midi Adapter with the end goal of eventually creating my own pro bass controller based around the arduino. The first thing I need to figure out is how to send the ‘keep-alive’ sysEx command the the controller uses to tell the adapter it’s still connected. I’m using the MIDI IN/OUT shield from tom scarff
(see: http://tomscarff.110mb.com/MIDI_IN_OUT_ARDUINO/midi_in_out_arduino.htm) to handle sending the actual midi info from the arduino to the adapter. Here is what my code looks like right now:

/*
NAME:                 MIDI Input to MIDI Output 
 WRITTEN BY:           TOM SCARFF
 DATE:                 4/10/2009
 FILE SAVED AS:        midi_in_out.pde
 FOR:                  Miduino ATmega168
 CLOCK:                16.00 MHz CRYSTAL                                        
 PROGRAMME FUNCTION:  Detect midi input and send to MIDI output.
                        digitalWrite(3, LOW); // GND 0 Volt supply to opto-coupler
                        digitalWrite(2, HIGH); // +5 Volt supply to opto-coupler
 

 HARDWARE NOTE:
 The Midi IN Socket is connected to the Miduino RX through an 6N139 opto-isolator
 *
 * To send MIDI, attach a MIDI out Female 180 Degree 5-Pin DIN socket to Arduino.
 * Socket is seen from solder tags at rear.
 * DIN-5 pinout is:                                         _______ 
 *    pin 2 - Gnd                                          /       \
 *    pin 4 - 220 ohm resistor to +5V                     | 1     3 |  MIDI jack
 *    pin 5 - Arduino Pin 1 (TX) via a 220 ohm resistor   |  4   5  |
 *    all other pins - unconnected                         \___2___/
 *
 *
 ***************************************************************************** 
 *
 */
 
#include <MIDI.h>
//variables setup

byte midiByte;
byte note;
byte velocity;
byte MIDIchannel;
byte x;
byte Flag1=0;
byte Flag2=0;

byte test;

byte data[16] = {0x08, 0x40, 0x0A, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
byte len=16;

int LedPin = 13;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int buttonPin = 24;               //choose the input pin for a pushbutton
int potPin = 0;                  //choose the input pin for a potentometer
int buttonVal = 0;                    //variable for reading the button status
int buttonState = 0;            //variable to hold the buttons current state
int bounceCheck = 0;            //variable for debouncing


//setup: declaring iputs and outputs and begin serial 
void setup() {
 
  pinMode(2, OUTPUT);     
  pinMode(3, OUTPUT);  
  digitalWrite(3, LOW); // GND 0 Volt supply to opto-coupler
  digitalWrite(2, HIGH); // +5 Volt supply to opto-coupler
  
  
  pinMode(4, INPUT); // Set Inputs for 4 way DIP Switch
  pinMode(5, INPUT); 
  pinMode(6, INPUT); 
  pinMode(7, INPUT); 
  digitalWrite(4, HIGH); // Set inputs Pull-up resistors High
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
 
  pinMode(LedPin,OUTPUT);   // declare the LED's pin as output
  pinMode(buttonPin, INPUT);     //declare pushbutton as input
  for (x=1; x<=4; x++){
    digitalWrite( LedPin, HIGH );
    delay(300);
    digitalWrite( LedPin, LOW );
    delay(300);
  }
  
  //start serial with midi baudrate 31250 or 38400 for debugging
  Serial.begin(31250);        

  Serial.flush();
}

//loop: wait for serial data, and output the message 
void loop () {
  
  buttonVal = digitalRead(buttonPin);     //read input value from button
  delay(10);                              //wait 10ms
  bounceCheck = digitalRead(buttonPin);   //check again
  if(buttonVal == bounceCheck){           //if val is the same then not a bounce
    if (buttonVal == HIGH && buttonState == 1) {   //check if the input is HIGH
      digitalWrite(LedPin, LOW);         //turn LED OFF
      Serial.println("OFF");
      buttonState = 0;
    }
    if(buttonVal == LOW && buttonState == 0){
      digitalWrite(LedPin, HIGH);       //turn LED ON
      Serial.println("ON");
      buttonState = 1;
    }

  }

  
   // Read 4-way DIP switch
//  MIDIchannel=digitalRead(4) + (digitalRead(5)<<1) + (digitalRead(6)<<2) + (digitalRead(7)<<3);
 
    if (MIDI.read()) {
    digitalWrite(LedPin,HIGH);     // Blink the LED
    MIDI.sendSysEx( len, data);
    MIDI.sendNoteOn(42,127,10);  // Send a Note (pitch 42, velo 127 on channel 1)
    delay(2000);		// Wait for a second
    MIDI.sendNoteOff(42,0,10);   // Stop the note
    digitalWrite(LedPin,LOW);    	
    }
       if (Serial.available() > 0) { 
          digitalWrite(LedPin,HIGH);   
          midiByte = Serial.read();
          Serial.print(midiByte,BYTE); 
          digitalWrite(LedPin,LOW);          
       }
}

unfortunately, there is something I’m missing. The adapter sees the connection but the the midi indicator blinks and turns off.

This is a pretty complex undertaking, can any of you DIY gurus give me an idea of what I could be doing wrong?

According to the manual the came with the RB pro adapter the midi indicator LED will flash in an SOS pattern if the ‘instrument’ is disconnected. When the code runs, the indicators turns on, flashes the SOS pattern and then shuts off. As for the delay, I should have commented out those 3 lines, I’m really only focused on getting the sysEx to work.

The first red flag I see is your Serial.println code in there. The MIDI code is using the serial port (it's just abstracting it out to a MIDI.xxx function), so when you're sending those non-MIDI strings via Serial, you're sending what amounts to corrupt MIDI data over the MIDI connection. I haven't had a chance to look closer and see if that's your only problem, but I doubt it's helping.

I went through and removed any code nor directly related to sending the sysEX or setting up the pins for the shield. Here is what I have left:

/*
NAME:                 MIDI Input to MIDI Output 
 WRITTEN BY:           TOM SCARFF
 DATE:                 4/10/2009
 FILE SAVED AS:        midi_in_out.pde
 FOR:                  Miduino ATmega168
 CLOCK:                16.00 MHz CRYSTAL                                        
 PROGRAMME FUNCTION:  Detect midi input and send to MIDI output.
                        digitalWrite(3, LOW); // GND 0 Volt supply to opto-coupler
                        digitalWrite(2, HIGH); // +5 Volt supply to opto-coupler
 

 HARDWARE NOTE:
 The Midi IN Socket is connected to the Miduino RX through an 6N139 opto-isolator
 *
 * To send MIDI, attach a MIDI out Female 180 Degree 5-Pin DIN socket to Arduino.
 * Socket is seen from solder tags at rear.
 * DIN-5 pinout is:                                         _______ 
 *    pin 2 - Gnd                                          /       \
 *    pin 4 - 220 ohm resistor to +5V                     | 1     3 |  MIDI jack
 *    pin 5 - Arduino Pin 1 (TX) via a 220 ohm resistor   |  4   5  |
 *    all other pins - unconnected                         \___2___/
 *
 *
 ***************************************************************************** 
 *
 */
 
#include <MIDI.h>
//variables setup

byte data[16] = {0x08, 0x40, 0x0A, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
byte len=16;

int LedPin = 13;   // select the pin for the LED
//setup: declaring iputs and outputs and begin serial 
void setup() {
 
  pinMode(2, OUTPUT);     
  pinMode(3, OUTPUT);  
  digitalWrite(3, LOW); // GND 0 Volt supply to opto-coupler
  digitalWrite(2, HIGH); // +5 Volt supply to opto-coupler
  
  pinMode(4, INPUT); // Set Inputs for 4 way DIP Switch
  pinMode(5, INPUT); 
  pinMode(6, INPUT); 
  pinMode(7, INPUT); 
  digitalWrite(4, HIGH); // Set inputs Pull-up resistors High
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
 
  pinMode(LedPin,OUTPUT);   // declare the LED's pin as output
  
  //start serial with midi baudrate 31250 or 38400 for debugging
//  Serial.begin(31250);        
  Serial.begin(38400); 
  Serial.flush();
}

//loop: wait for serial data, and output the message 
void loop () {

    MIDI.sendSysEx( len, data);
}

I’m still seeing the same behavior.

One possiblity I was looking at is that the shield hardware doesn’t quite match the diagram, pins 4 and 5 of the MIDI -out are hooked up but there is no connection from 2 to gnd. I’m a little concerned about connecting that directly to the arduino since the MIDI is normally seperated by an opto-isolator. Any thoughts?

I tried replacing the Serial.begin and Serial.flush with Midi.begin() but it didn't seem to make any difference.

I managed to solve the problem. The issue wasn't my code it was my faulty assumptions. Since the pro-guitars send a 'keep-alive' sysex I had assumed that the drums would do the same. Turns out all I had to do was just send the notOn/noteOff, the drums don;t require any special sysex commands. I was also wrong about the indicator LED on the pro adapter. It does display an SOS pattern when an instument is disconnected, but during normal operation it only flashes when a message is recieved.

Thanks for all the patient help.