Arduion2Max/Motor Shield integration

I'm having an issue with the arduino2max program for the Arduino. I am using the Arduino Motor Shield to run two separate stepper motors. Each of these motors is activated by a switch inside of a coin slot. People will use nickels in order to start these motors. Basically the motors are activated and then start turning music boxes which are attached to them. When the switch is hit, in addition to running the motors, my program needs to give a simple bang to Max. I'm only using Analog 0 and 1 on the motor shield. With this bang, it starts a recording process that captures the music box sequence. Then, when the motors are done stepping, it goes on to perform a generative piece from the captured music box in the buffer for a couple of minutes.

My problem is, anytime I try to integrate any little bit of code into the arduino4max program, it doesn't work. I can't seem to communicate to both. Is there anyway to integrate additional code into the loop of Arduino2Max? Or would anyone know an easier way without using Arduino2Max?
All I need are running motor(s) and a bang in Max when the switch is hit.

THANKS!

Here is my code for simply hitting the switch and running the motors (which works fine)...

#include <AFMotor.h>

AF_Stepper motor(200, 1);
AF_Stepper motor2(200, 2);

/GLOBAL VARIABLES/

int analogPin = 0;
int analogPin2 = 1;

int val = 0;
int val2 = 0;

int counter = 0;
int counter2 = 0;

void setup() {
Serial.println("THE MUSIC BOXES");
Serial.begin(9600);

/MOTOR SETUP/
motor.setSpeed(1);
motor2.setSpeed(1);
}

void loop() {

/FIRST SWITCH/

val = analogRead(analogPin); // read the input pin

//Serial.println(val); // debug value

if(counter >= 120) {
Serial.println("COIN IN");
delay(1500);
motor.step(60, FORWARD, DOUBLE);
release();
counter = 0;
delay(200);
}
else {
if(val == 1023) {
counter++;
}
else {
counter = 0;
}
}

/SECOND SWITCH/

val2 = analogRead(analogPin2);

if(counter2 >= 120) {
Serial.println("COIN 2 IN");
delay(1500);
motor2.step(60, FORWARD, DOUBLE);
release();
counter2 = 0;
delay(200);
}
else {
if(val2 == 1023) {
counter2++;
}
else {
counter2 = 0;
}
}
}

Here's the arduino2max program...

/*

  • Arduino2Max
  • Send pin values from Arduino to MAX/MSP
  • Arduino2Max.pde

  • This version: .4, October 2007

  • Copyleft: use as you like
  • by Daniel Jolliffe
  • Based on a sketch and patch by Thomas Ouellet Fredericks tof.danslchamp.org

*/

int x = 0; // a place to hold pin values
int ledpin = 13;

void setup()
{
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}

void loop()
{

if (Serial.available() > 0){ // Check serial buffer for characters

if (Serial.read() == 'r') { // If an 'r' is received then read the pins

for (int pin= 0; pin<=5; pin++){ // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);
}

for (int pin= 2; pin<=13; pin++){ // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);
}

Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (5); // add a delay to prevent crashing/overloading of the serial port

}

}
}

void sendValue (int x){ // function to send the pin value followed by a "space".
Serial.print(x);
Serial.print(32, BYTE);
}