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?