Get serial information from Arduino to MAX/MSP?
Hi,
I need to communicate between the Arduino and MAX/MSP, I have wrote a simple Arduino code that prints the integer 376. But when I recieve that in MAX/MSP I only get the ASCII codes(51, 55 and 54). How to I get the integer from Arduino to MAX/MSP or how can I convert the ASCII codes to integer in MAX/MSP?
Arduino code:
int id = 376;
void setup (){
Serial.begin(9600);
}
void loop(){
Serial.print(id);
delay(2000);
}
MAX/MSP code:
Kind Regards
2 things:
in your arduino code, you need to send some special char when you're done sending your number (so Max knows when it received all the bytes). You could use Serial.println() for that.
In Max, you can use itoa for the conversion, more or less this way:
Hi Patrick!
It was exactly what I was looking for :)
Thanks!
Or, it was almost exactly what I was looking for.
I have now connected a compass module to the Arduino and I can read the Serial.print() to MAX/MSP(to get the heading, 0 - 360). Now I also want to connect a button to the Arduino, then I will need two Serial.println(I think if its not a alternate way?), but how can I connect two Serial.println() to MAX/MSP?
Regards Sigurd
You can do something like the following
Serial.print(id);
Serial.print("_");
Serial.println(buttonState);
and parse it in Max:
You'll get a list of 2 values, the first item being the id.
Hi,
I did what you presented above, but I couldnt make it work. Im not very skilled at MAX/MSP - can you please tell me how I should use it?
My max patch:
Regards
Hi,
I don't have much time now...
The [p decode 2] outputs a _list_ of 2 numbers, so you need to insert an [unpack 1 1] between its output and the rest of your code. As I wrote in my previous post, the first value is the id
p
Patrick - the [unpack 1 1] did the trick.
It now works just fine!
Thank you for your help!
Best,
Sigurd
Hi guys,
I have two boards: arduino uno + seeeduino. I need to read both in Max, so I'd need to use two [serial] objects, but my tests failed.
Which is the method?
Thanks a lot.