Arduino Zero Pro in Max/Msp


    Jan 09 2016 | 1:46 pm
    Hello everyone,
    I just bought a new arduino zero, i get the numbers on serial monitor in arduino.app but nothing in max/msp. I read already tons of infos about serial communication, tried almost everything - no luck. Exactly the same code, same script etc works perfectly on my arduino due, and uno board.
    Any arduino freak who could help? :)
    Thanks!

    • Jan 10 2016 | 10:31 pm
      Hi, in the meantime i managed to solve the problem!
      In order to start serial communication on ARDUINO ZERO PRO (M0 Pro) you need to enable DTR mode otherwise you won't get any data transfer.
      Here a simple code both for arduino and max :
      Arduino Zero Pro :
      void setup() { Serial.begin(57600); } void loop() {
      int sensorValue = analogRead(A0);
      Serial.println(sensorValue); delay(1); }
      Max:
      { "boxes" : [ { "box" : { "maxclass" : "comment", "text" : "the serial.read on pin A0 will appear here", "numinlets" : 1, "style" : "", "numoutlets" : 0, "presentation_rect" : [ 75.800049, 587.5, 0.0, 0.0 ], "patching_rect" : [ 69.800049, 587.5, 228.0, 20.0 ], "id" : "obj-9" }
      } , { "box" : { "maxclass" : "comment", "text" : "3 start getting data from arduino", "linecount" : 2, "numinlets" : 1, "style" : "", "numoutlets" : 0, "presentation_rect" : [ 142.800049, 271.0, 0.0, 0.0 ], "patching_rect" : [ 142.800049, 270.5, 156.0, 33.0 ], "id" : "obj-8" }
      } , { "box" : { "maxclass" : "comment", "text" : "2 select your arduino board", "numinlets" : 1, "style" : "", "numoutlets" : 0, "patching_rect" : [ 111.800049, 136.0, 156.0, 20.0 ], "id" : "obj-7" }
      } , { "box" : { "maxclass" : "comment", "text" : "1 update the menu", "numinlets" : 1, "style" : "", "numoutlets" : 0, "patching_rect" : [ 60.300049, 92.374634, 111.0, 20.0 ], "id" : "obj-4" }
      } , { "box" : { "maxclass" : "toggle", "parameter_enable" : 0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "int" ], "patching_rect" : [ 98.800049, 261.0, 39.0, 39.0 ], "id" : "obj-38" }
      } , { "box" : { "maxclass" : "number", "parameter_enable" : 0, "fontsize" : 12.0, "numinlets" : 1, "style" : "", "numoutlets" : 2, "outlettype" : [ "", "bang" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 559.0, 50.0, 22.0 ], "id" : "obj-3" }
      } , { "box" : { "maxclass" : "newobj", "text" : "fromsymbol", "fontsize" : 12.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 504.0, 74.0, 22.0 ], "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], "id" : "obj-138" }
      } , { "box" : { "maxclass" : "newobj", "text" : "itoa", "fontsize" : 12.0, "numinlets" : 3, "style" : "", "numoutlets" : 1, "outlettype" : [ "int" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 481.0, 46.0, 22.0 ], "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], "id" : "obj-140" }
      } , { "box" : { "maxclass" : "newobj", "text" : "zl group", "fontsize" : 12.0, "numinlets" : 2, "style" : "", "numoutlets" : 2, "outlettype" : [ "", "" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 458.0, 53.0, 22.0 ], "id" : "obj-141" }
      } , { "box" : { "maxclass" : "newobj", "text" : "select 10 13", "fontsize" : 12.0, "numinlets" : 3, "style" : "", "numoutlets" : 3, "outlettype" : [ "bang", "bang", "" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 431.211121, 77.0, 22.0 ], "id" : "obj-144" }
      } , { "box" : { "maxclass" : "newobj", "text" : "unpack 0", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "int" ], "fontname" : "Verdana", "patching_rect" : [ 69.800049, 530.0, 56.0, 21.0 ], "id" : "obj-146" }
      } , { "box" : { "maxclass" : "newobj", "text" : "qmetro 1", "fontsize" : 12.0, "numinlets" : 2, "style" : "", "numoutlets" : 1, "outlettype" : [ "bang" ], "fontname" : "Arial", "patching_rect" : [ 86.800049, 353.0, 58.0, 22.0 ], "id" : "obj-5" }
      } , { "box" : { "maxclass" : "newobj", "text" : "p devices", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "clear" ], "fontname" : "Trebuchet MS", "patching_rect" : [ 34.800049, 116.872559, 52.0, 20.0 ], "id" : "obj-128", "patcher" : { "fileversion" : 1, "appversion" : { "major" : 7, "minor" : 1, "revision" : 0, "architecture" : "x86", "modernui" : 1 } , "rect" : [ 703.0, 313.0, 667.0, 547.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, "default_fontface" : 0, "default_fontname" : "Arial", "gridonopen" : 1, "gridsize" : [ 15.0, 15.0 ], "gridsnaponopen" : 1, "objectsnaponopen" : 1, "statusbarvisible" : 2, "toolbarvisible" : 1, "lefttoolbarpinned" : 0, "toptoolbarpinned" : 0, "righttoolbarpinned" : 0, "bottomtoolbarpinned" : 0, "toolbars_unpinned_last_save" : 0, "tallnewobj" : 0, "boxanimatetime" : 200, "enablehscroll" : 1, "enablevscroll" : 1, "devicewidth" : 0.0, "description" : "", "digest" : "", "tags" : "", "style" : "", "subpatcher_template" : "", "boxes" : [ { "box" : { "maxclass" : "newobj", "text" : "loadbang", "fontsize" : 12.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "bang" ], "fontname" : "Arial", "patching_rect" : [ 219.0, 45.0, 60.0, 22.0 ], "id" : "obj-2" }
      } , { "box" : { "maxclass" : "message", "text" : "select...", "fontsize" : 12.0, "numinlets" : 2, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Arial", "patching_rect" : [ 148.0, 258.0, 52.0, 22.0 ], "id" : "obj-10" }
      } , { "box" : { "maxclass" : "newobj", "text" : "t print b clear", "fontsize" : 12.0, "numinlets" : 1, "style" : "", "numoutlets" : 3, "outlettype" : [ "print", "bang", "clear" ], "fontname" : "Arial", "patching_rect" : [ 51.0, 76.0, 80.0, 22.0 ], "id" : "obj-8" }
      } , { "box" : { "maxclass" : "newobj", "text" : "route port", "fontsize" : 10.0, "numinlets" : 2, "style" : "", "numoutlets" : 2, "outlettype" : [ "", "" ], "fontname" : "Arial", "patching_rect" : [ 90.0, 171.0, 56.0, 20.0 ], "id" : "obj-1" }
      } , { "box" : { "maxclass" : "newobj", "text" : "prepend append", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Arial", "patching_rect" : [ 90.0, 358.0, 111.0, 20.0 ], "id" : "obj-3" }
      } , { "box" : { "maxclass" : "newobj", "text" : "serial", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 2, "outlettype" : [ "int", "" ], "fontname" : "Arial", "patching_rect" : [ 64.0, 115.0, 36.0, 20.0 ], "id" : "obj-4" }
      } , { "box" : { "maxclass" : "newobj", "text" : "iter", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Arial", "patching_rect" : [ 31.0, 271.0, 25.0, 20.0 ], "id" : "obj-5" }
      } , { "box" : { "maxclass" : "inlet", "numinlets" : 0, "style" : "", "numoutlets" : 1, "outlettype" : [ "bang" ], "patching_rect" : [ 64.0, 45.0, 15.0, 15.0 ], "id" : "obj-6", "comment" : "" }
      } , { "box" : { "maxclass" : "outlet", "numinlets" : 1, "style" : "", "numoutlets" : 0, "patching_rect" : [ 148.0, 432.0, 15.0, 15.0 ], "id" : "obj-7", "comment" : "" }
      } ], "lines" : [ { "patchline" : { "source" : [ "obj-8", 2 ], "destination" : [ "obj-7", 0 ], "hidden" : 0, "midpoints" : [ 364.0, 251.0 ], "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-8", 0 ], "destination" : [ "obj-4", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-8", 1 ], "destination" : [ "obj-10", 0 ], "hidden" : 0, "midpoints" : [ 229.0, 217.0 ], "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-6", 0 ], "destination" : [ "obj-8", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-5", 0 ], "destination" : [ "obj-3", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-4", 1 ], "destination" : [ "obj-1", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-3", 0 ], "destination" : [ "obj-7", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-2", 0 ], "destination" : [ "obj-8", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-10", 0 ], "destination" : [ "obj-3", 0 ], "hidden" : 0, "midpoints" : [ 106.0, 260.0 ], "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-1", 0 ], "destination" : [ "obj-5", 0 ], "hidden" : 0, "disabled" : 0 }
      } ] } , "saved_object_attributes" : { "description" : "", "digest" : "", "globalpatchername" : "", "style" : "", "tags" : "" }
      }
      } , { "box" : { "maxclass" : "button", "numinlets" : 1, "style" : "", "numoutlets" : 1, "presentation_rect" : [ 58.235035, 110.308456, 22.000002, 22.000002 ], "outlettype" : [ "bang" ], "patching_rect" : [ 35.387451, 92.374634, 20.0, 20.0 ], "presentation" : 1, "id" : "obj-33" }
      } , { "box" : { "maxclass" : "umenu", "parameter_enable" : 0, "pattrmode" : 1, "numinlets" : 1, "style" : "", "numoutlets" : 3, "presentation_rect" : [ 78.135056, 110.308456, 75.0, 22.0 ], "items" : [ "select...", ",", "Bluetooth-Incoming-Port", ",", "Bluetooth-Modem" ], "outlettype" : [ "int", "", "" ], "fontname" : "Trebuchet MS", "allowdrag" : 0, "patching_rect" : [ 34.800049, 136.0, 75.0, 22.0 ], "presentation" : 1, "arrow" : 0, "id" : "obj-2" }
      } , { "box" : { "maxclass" : "newobj", "text" : "prepend port", "fontsize" : 10.0, "numinlets" : 1, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Trebuchet MS", "patching_rect" : [ 62.800049, 166.355286, 69.0, 20.0 ], "id" : "obj-150" }
      } , { "box" : { "maxclass" : "message", "text" : "dtr $1", "fontsize" : 13.0, "numinlets" : 2, "style" : "", "numoutlets" : 1, "outlettype" : [ "" ], "fontname" : "Arial", "patching_rect" : [ 146.800049, 353.0, 45.0, 23.0 ], "id" : "obj-11" }
      } , { "box" : { "maxclass" : "newobj", "text" : "serial a 57600", "fontsize" : 13.0, "numinlets" : 1, "style" : "", "numoutlets" : 2, "outlettype" : [ "int", "" ], "fontname" : "Arial", "patching_rect" : [ 69.800049, 401.0, 92.0, 23.0 ], "id" : "obj-37" }
      } ], "lines" : [ { "patchline" : { "source" : [ "obj-33", 0 ], "destination" : [ "obj-2", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-38", 0 ], "destination" : [ "obj-11", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-38", 0 ], "destination" : [ "obj-5", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-138", 0 ], "destination" : [ "obj-146", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-146", 0 ], "destination" : [ "obj-3", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-5", 0 ], "destination" : [ "obj-37", 0 ], "hidden" : 0, "midpoints" : [ 96.300049, 387.0, 79.300049, 387.0 ], "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-37", 0 ], "destination" : [ "obj-144", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-33", 0 ], "destination" : [ "obj-128", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-2", 1 ], "destination" : [ "obj-150", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-150", 0 ], "destination" : [ "obj-37", 0 ], "hidden" : 0, "midpoints" : [ 72.300049, 339.0, 72.0, 339.0, 72.0, 387.0, 79.300049, 387.0 ], "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-144", 0 ], "destination" : [ "obj-141", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-144", 2 ], "destination" : [ "obj-141", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-141", 0 ], "destination" : [ "obj-140", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-140", 0 ], "destination" : [ "obj-138", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-128", 0 ], "destination" : [ "obj-2", 0 ], "hidden" : 0, "disabled" : 0 }
      } , { "patchline" : { "source" : [ "obj-11", 0 ], "destination" : [ "obj-37", 0 ], "hidden" : 0, "midpoints" : [ 156.300049, 387.0, 79.300049, 387.0 ], "disabled" : 0 }
      } ], "appversion" : { "major" : 7, "minor" : 1, "revision" : 0, "architecture" : "x86", "modernui" : 1 }
      }
    • Jan 10 2016 | 11:38 pm
      Rafal, thanks for sharing. Posting the Arduino code with the Max patch is very helpful. Be sure to check out the Copy Compressed feature in the Edit menu. It's the preferred way of posting patches on the forum. Like this...