hello
I'm running solenoid patterns off of midi playing from a simple max msp patch outputting to the arduino. When I hit start in the msp patch it plays the midi for about 30 seconds perfectly, then the solenoids stop running, the patch keeps playing but my mouse freezes and the computer crashes, and the program stops. The only way I've seen that will prevent the computer from crashing is if I keep my mouse active by moving it around, but the solenoids and everything else stop. The computer still basically needs to be restarted. When I run the patch on its own it runs fine (with no serial connect) Anyways, I really am not sure where I'm going wrong here. I'm running a macbook Air 10.73. I've tried it also with a few different boards.
Here is the code I'm working with right now.
int incomingByte = 0;
void setup() { Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(14, OUTPUT); pinMode(15, OUTPUT);
} void loop() {
if (Serial.available() > 0) { incomingByte = Serial.read(); Serial.print ("I received: "); Serial.println(incomingByte, DEC);
}
if (incomingByte == 148) { digitalWrite(2, HIGH); }
if (incomingByte == 48) { digitalWrite(2, LOW);
}
if (incomingByte == 149) { digitalWrite(3, HIGH); }
if (incomingByte == 49) { digitalWrite(3, LOW);}
if (incomingByte == 150) { digitalWrite(4, HIGH); }
if (incomingByte == 50) { digitalWrite(4, LOW);
}
if (incomingByte == 151) { digitalWrite(5, HIGH);}
if (incomingByte == 51) { digitalWrite(5, LOW); }
if (incomingByte == 152) { digitalWrite(6, HIGH); }
if (incomingByte == 52) { digitalWrite(6, LOW);
}
if (incomingByte == 153) { digitalWrite(7, HIGH); }
if (incomingByte == 53) { digitalWrite(7, LOW);
}
if (incomingByte == 156) { digitalWrite(10, HIGH); }
if (incomingByte == 56) { digitalWrite(10, LOW);
}
if (incomingByte == 157) { digitalWrite(11, HIGH); }
if (incomingByte == 57) { digitalWrite(11, LOW);
}
if (incomingByte == 158) { digitalWrite(12, HIGH); }
if (incomingByte == 58) { digitalWrite(12, LOW);
}
if (incomingByte == 159) { digitalWrite(13, HIGH); }
if (incomingByte == 59) { digitalWrite(13, LOW);
}
if (incomingByte == 154) { digitalWrite(14, HIGH); }
if (incomingByte == 54) { digitalWrite(14, LOW);
}
if (incomingByte == 155) { digitalWrite(15, HIGH); }
if (incomingByte == 55) { digitalWrite(15, LOW); }
}
Thanks for the help!!