MIDI to VMDX

I am a newbie who has problems with a simple sketch. I don't know where the problem is originating from, either programming or the electronics. My sketch is a simple loop that sends a signal on PIN 2 and simultaneously sends MIDI information to the computer (VDMX - a vj software on the mac).

I have 2 Arduino chips, both exhibit the same problem. I have flashed the Arduinos to install HIDUINO and I keep having the problem. The Arduino either handles the MIDI or the PIN 2 just fine. However, when it tries to do both, it keeps reliably sending the PIN 2 information, but the MIDI stops after a limited number of cycles (under a minute most of the time). The TX light switches on on the Arduino and no more MIDI signal is sent out. If I restart the Arduino, the MIDI works reliably for a limited number of cycles.

Here is the code:

const int solenoidPin = 2;

void setup() { pinMode(solenoidPin, OUTPUT);//initialize solenoid output (through transistor then relay) Serial.begin(31250); //send an receive to computer MIDI note

}

void loop() {

digitalWrite(solenoidPin, HIGH); noteOn(0x90,60,0x45); //Note on channel 1 (0x90), note value (60), middle velocity (0x45): delay(300); noteOn(0x90,60,0x00); //Note on channel 1 decreases to 0 delay(1050);

digitalWrite(solenoidPin, LOW); noteOn(0x90,60,0x45); // note value (60) delay(300); noteOn(0x90,60,0x00);//Note on channel 1 decreases to 0 delay(1000); }

void noteOn(int cmd, int pitch, int velocity) { Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); }

const int solenoidPin = 2;

What, exactly, is connected to this pin? The more details, the better.

The TX light switches on on the Arduino and no more MIDI signal is sent out.

The TX light stays on? Or, was one of those ons supposed to be an off?