help with arduino multiple messages

Jul 6, 2011 at 8:43pm

help with arduino multiple messages

Hi,
I been banging my head trying to figure it out how to get
max msp to unpack 2 sensors data.

here is my max patch fallow by arduino stech.
any help is welcome

– Pasted Max Patch, click to expand. –

+++++++++++++++++++++++++++++++++++
arduino code

========================

int potPin = 5; // select the input pin for the potentiometer
int potpin2 = 2;
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
int val2 =0;
void setup() {
Serial.begin(57600);

}

void loop() {
val2 = analogRead(potpin2);
val = analogRead(potPin); // read the value from the sensor

Serial.println(val);
delay (10);
Serial.println(val2);

delay (10);

}

#57901
Jul 6, 2011 at 10:56pm

You can add an index before the value in your arduino script :

Serial.print(“1 “);
Serial.println(val);

and respectively :
Serial.print(“2 “);
Serial.println(val2);

and in your max patch you add a route object:

– Pasted Max Patch, click to expand. –

jan

#207731
Jul 6, 2011 at 11:10pm

Or you could use Jan’s method of a Serial.print followed by a Serial.prinln to put both values in the same serial message and then use unpack to get the results in Max.

#207732
Jul 13, 2011 at 12:26am

looks like it works.
thanks guys

#207733

You must be logged in to reply to this topic.