Interfacing Ultrasonic Sensor with Arduino BT


Does anyone know how to change this code to get my PING Ultrasonic Sensor connected to the Arduino BT to speak to Max/MSP? I will forever be indebted to you!! :-/

int pingPin = 7;

void setup() { Serial.begin(9600); }

void loop() { long duration, inches, cm;

pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH);

inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration);

Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println();

delay(100); }

long microsecondsToInches(long microseconds) {

return microseconds / 74 / 2; }

long microsecondsToCentimeters(long microseconds) {

return microseconds / 29 / 2; }

Hmmm..I found that wherever I have a baud rate of 9600, I should change to 115200 for the arduino BT....

My apologies for being such a newbie..