unpack several serial data from arduino ?(sorry, privous posts are wrong,)

Apr 25, 2013 at 10:20am

unpack several serial data from arduino ?(sorry, privous posts are wrong,)

(sorry, privous posts are wrong, but I can’t find delete icon)

I have three analogin from arduino (three light sensors), and want to receive the serial data from them seperately.
But now the max receives the data all in one, not seperately. (attached picture, plz watch red circle)
What should I do between serial c 9600 object and unpakc opject in the picture attached ?

arduino code:

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

void loop()
{
int sensorValue = analogRead(A1);
int sensorValue2 = analogRead(A2);
int sensorValue3 = analogRead(A3);
Serial.write(sensorValue);
Serial.write(sensorValue2);
Serial.write(sensorValue3);

}

[attachment=222093,5487] [attachment=222093,5488]

Attachments:
  1. 2.jpg
#67938
Apr 25, 2013 at 11:01am

I’ve attached a zip file with Max patch and Arduino sketch. Have a look inside the subpatch for how to match & unpack the data coming from Arduino.

#244214
Apr 25, 2013 at 11:05am

That one was mostly just to directly (more or less) answer your question. It’s not optimum, however, for a variety of reasons. See the files attached here for a better way of handling it.

#244215
Apr 25, 2013 at 12:12pm

I copy&pasted match object between unpack and serial opject, using the patch you uploaded, and it finally works. Thank you a lot Steven.

#244216
Apr 25, 2013 at 1:36pm

You’re welcome. Have fun with it!

#244217

You must be logged in to reply to this topic.