arduino2max using MEGA 2560 problem

Hi, I’m having some problems reading output from an Arduino MEGA 2560 into max/msp using arduino2max. I have an UNO and the arduino code and max patch work fine together but I needed a lot more analogue pins so I bought a MEGA. I uploaded the BLINK example code and it runs fine on the MEGA, just to check it was working, then I uploaded the arduino2max code (modified to read the extra pins). The max patch wont read anything from the COM port when I select it. If i have the UNO plugged in still I can read that fine. Drivers are all up to date.

here is the code i’m using(the only parts I modified were to read 15 A pins and 52 D pins):

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<=15; pin++){      // Read and send analog pins 0-5
    x = analogRead(pin);
    sendValue (x);
    }



for (int pin= 2; pin<=53; 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.write(32); 
}

Any help would be amazing!

HI

The old version (v .5) of Arduino2Max didn't work with the Uno because the the command to print byte values had changed. I just got around to uploading a newer version (v .6 November 2012) that works with Uno.
See the playground.

D

PS: you will have to change the MAX patch end also for a MEGA version.
There's a "zl group" Object that might have to be bigger, and also the "route list" at the bottom of the patch will have to be wider.

D