Arduino 2 Max msp code not working with Mega?

I'm trying to get this code to work with an arduino mega but having no luck, It works fine with the Uno but I get no connection between Arduino and Max MSP when using the mega board and can't figure out why?

I'm new to arduino but I think I understand the concept of the code, the arduino reads the inputs from Pins 0-6 and uses 'int x' to store the value of the pins, this then gets printed to the serial monitor and Max reads the serial connection and unpacks the data (at the patch end). I don't understand why this isn't working with the mega though, do they not have the same architecture?

The code is posted below:

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.write(32);
}

Any help would be appreciated on this, I've even tried writing my own code but like I say I'm new to arduino and keep getting tripped up by error messages.

What happens if you open the Serial Monitor application, instead?

There are no values displayed in the serial monitor in Arduino, I have an LDR hooked up to the mega but it's not printing the resistance?

There are no values displayed in the serial monitor in Arduino

What about a simple "Hello world" sketch?

Used a hello world sketch and it printed to the serial fine, I also tested the LDR with an AnalogReadSerial sketch and that worked fine as well?

and that worked fine as well?

Is that a question or a statement?

If other sketches send data to the Serial Monitor application correctly, this one should, too. When you ran that sketch, with the Serial Monitor application, did you send 'r'? That sketch does nothing until it receives a 'r'.