Problem with the call and response max/arduino example ...

Kaspar's icon

Hi,

I have made the following max / arduino tutorial: http://arduino.cc/en/Tutorial/SerialCallResponse

Yes, it works, the sensor data comes out into the three number boxes, but there is a problem:
- everytime I hook up the arduino, the sensor signals appear in different number boxes. This means that I need to find out which sensor comes out into which number box, everytime I boot max.

My question is: How do I make sure that the sensor signal from A1 is routed into the first number box, the sensor signal A2 is routed into the second number box etc, everytime I open max?

Thanks for your help!

K

brendan mccloskey's icon

Hi
prefix each sensor with a unique ID:

Serial.print("1");//ascii 49
Serial.print(yourOwnSensorValueHere, BYTE);
Serial.print("2");//ascii 50
Serial.print(anotherSensorValueHere, BYTE);

etc

then in Max use a combination of [zl group 2] and [route 49 50]. This very short video of mine explains how:

just replace the random val1, random val2 etc with your own sensor values

Brendan (fCast)

Scott Fitzgerald's icon

The reason this is happening is because the Arduino is pinging the attached computer waiting for a serial port to open, there's a byte sitting in the buffer, causing everything to shift over one.

Thanks for pointing this out, I'll address it for the next Arduino software release.

Scott Fitzgerald's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a patch that addresses the issue for that specific example. If you have trouble, please let me know.