Sending two different data from Arduino to Max
Hi,
I have an Arduino patch that is receiving a data from an UltraSonic sensor and another patch that receiving a data from a photoResistor cell. Right now I manage to receive those datas separately into Max msp via the Serial object. I was wondering how can I have both data sending from arduino into two different Serial ports in Max patch ?
Thanks for any help
You should form Your questions more understandable.
Sorry for my wording.
I hope this one will be clearer:
I try to send two streams of data from Arduino to max.
One stream of data is from an ultrasonic sensor and the other from a photo resistor cell.
I got no issue sending each stream of data separately from Arduino to Max using Serial.print in Arduino and Serial object in Max.
The problem for me is to understand how to send two streams of data from Arduino into Max and have them independent from each other inside Max.
option 1:
Serial.print(sensor1); Serial.print(" "); Serial.println(sensor2);
option 2:
Serial.print("A "); Serial.println(sensor1); Serial.print("B "); Serial.println(sensor2);
-----
Which is better depends on ammount of data.
Prepending a letter as ID and sending only sensor that changed,
would reduce serial traffic.
Forming a list like in option 1 would allways send all sensors state,
no matter if they changed or not.
Thank you! That was exactly what I needed!
I have another question within this topic -
For the moment I successfully receiving and processing multiple data from Arduino in Max patch.
Now I try to understand how can I sending back data within the same patch from Max to be received in Arduino. ( I try to send 0 and 1 to switch led on and off in Arduino.
Thanks!
You need to send ASCII to arduino.
one would use atoi for that.
In this simple case (just turn 1 led on / off)
this would be ok :
in the patch is arduino code to toggle or fade LED
on pin 11, which should be pwm capable on most boards
Great! thanks for your kind explanations!