Ultrasonic range finder/Max MSP help

Hi

I'm trying to set up what I expected to be a simple installation. Basically I want to use the data from an ultrasonic range finder to manipulate certain parameters in Max Msp (such as amount of delay etc)
The equipment I'm using:

DYP ME007 Ultrasonic range finder
Arduino UNO
Max/MSP 5

Code for the ME007:
int outputPin = 2; // set you output pin
int inputPin = 3; // set your input pin
long distance;
long cm;
void setup(){
Serial.begin(9600); // set your baud rate
pinMode(outputPin, OUTPUT);
pinMode(inputPin,INPUT);
}
void loop()

{
digitalWrite(outputPin, LOW);
delayMicroseconds(2);
digitalWrite(outputPin, HIGH);
delayMicroseconds(10);
digitalWrite(outputPin, LOW);
distance = pulseIn(inputPin, HIGH); //it now initalizes before setup to speed up the process
cm= distance/58; //I don't like reusing the same variable name, it probably works fine though,
//but i don't really trust it, besides you have plenty of memory for it.
Serial.println(cm);
delay(500); // this will slow down your readings to 2 per second it should help when watching the Serial terminal
// if this helps then start to shrink it down to 100 then 10 then 1, maybe even go to microsecond delays or remove completely if it stops freezing
}

Using this code the sensor works fine with the arduino on their own. I have also managed to setup a connection between the arduino and Max. The problem is when I try to use all three.
I cannot work out how to access the sensor's data in Max (the LED on arduino does still pulse though, so guessing it is still working) Have tried Arduino2Max, Maxuino, Sensorbox etc, but still can't work it out!

Someone also suggested codes into the sensor code, but I wouldn't know where to start with that.

Any assistance will be most appreciated.

this is a max related question. you should have posted this in here: Forum | Cycling '74

First check with Serial Monitor to see if you get any results. Afterwards you can try what I posted below.
This worked for me. It's a max patch that is copied compressed:


----------begin_max5_patcher----------
1299.3oc0YsrjiZCEcM8WAEq8zkjPlGYWxp7OLUptjAY2JAPt.YO8LSM+6QH
wy1HdXicb7B.IAhy8bev8d8OewxYG+CZgi8uY+UaKqe9hkkZpxIrpFa4jR9H
JgTntMmL52369amM5kDzODpoOlyxD0ydjHhdmkc3sbZjPu4HzqfM1H+skmbw
pAfWA1+U0ivhUaibq+Bpda1yyDYjTpZkeOmQRpWI6TJKKgJTPB1NI+jndVPm
Mof8C0l.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