Forums > MaxMSP

is possible to read Serial data as text arduino – maxmsp

November 11, 2010 | 9:30 pm

if I have a arduino sketch that does
read a analog sensor then does Serial.println ("a");
how can I read it with max so that will show letter a being printed


November 11, 2010 | 9:57 pm

Not sure wat you mean exactly but i think you need the "itoa"-object. Integer to ascii-conversion.

FRid

– Pasted Max Patch, click to expand. –

November 11, 2010 | 10:01 pm

thankyou.
More about my question.

1- arduino with sensor, when sensor a is triger
adruino prints serial A
2- analog sensor is triger
arduino do serial print b

in max how can it read serial in ascii format


November 11, 2010 | 10:13 pm

I don’t get it, the patch i sent you converts int to asci and asci to int back so what exactly do you need? Maybe you could send an example-patch so i know wat it is you’re after.

FRid


November 11, 2010 | 10:18 pm

{
"boxes" : [ {
"box" : {
"maxclass" : "message",
"text" : "a",
"patching_rect" : [ 201.0, 543.0, 50.0, 18.0 ],
"id" : "obj-10",
"fontname" : "Arial",
"numinlets" : 2,
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ]
}

}
, {
"box" : {
"maxclass" : "number",
"patching_rect" : [ 197.0, 495.0, 50.0, 20.0 ],
"id" : "obj-8",
"fontname" : "Arial",
"numinlets" : 1,
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "bang" ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "atoi",
"patching_rect" : [ 197.0, 471.0, 46.0, 20.0 ],
"id" : "obj-6",
"fontname" : "Arial",
"numinlets" : 3,
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "list" ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "itoa",
"patching_rect" : [ 197.0, 518.0, 46.0, 20.0 ],
"id" : "obj-1",
"fontname" : "Arial",
"numinlets" : 3,
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "int" ]
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "a",
"patching_rect" : [ 197.0, 449.0, 32.5, 18.0 ],
"id" : "obj-4",
"fontname" : "Arial",
"numinlets" : 2,
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "" ]
}

}
, {
"box" : {
"maxclass" : "toggle",
"patching_rect" : [ 168.0, 277.0, 20.0, 20.0 ],
"id" : "obj-3",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 5",
"patching_rect" : [ 168.0, 322.0, 51.0, 20.0 ],
"id" : "obj-2",
"fontname" : "Arial",
"numinlets" : 2,
"numoutlets" : 1,
"fontsize" : 12.0,
"outlettype" : [ "bang" ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"patching_rect" : [ 168.0, 367.0, 79.0, 20.0 ],
"id" : "obj-31",
"fontname" : "Arial",
"numinlets" : 1,
"numoutlets" : 2,
"fontsize" : 12.0,
"outlettype" : [ "int", "" ]
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-31", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-4", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-8", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-10", 1 ],
"hidden" : 0,
"midpoints" : [ 206.5, 540.0, 241.5, 540.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-2", 0 ],
"destination" : [ "obj-31", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-2", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}


November 12, 2010 | 2:27 am

Hi,

you connected the output from serial to the left input of the message-box. Anything that is connected to the left inlet of message gets treated like a bang. If you want the message-box filled use the right inlet, doing this will only fill the message. You will need to use a bang to transfer the message to the hence the "t" object.

FRid

-When posting patches to the forum please use [select all or ctrl/command A] , [copy compressed] in an unlocked patch.

– Pasted Max Patch, click to expand. –

Viewing 6 posts - 1 through 6 (of 6 total)