Max5 + serial object + Arduino

    Feb 12 2009 | 4:49 am
    Max doesn't seems to be playing well with an Arduino Duemilanove. I loaded the example program onto the Arduino with Arduino 0013 programming environment. I open the Serial Communication tutorial. The correct serial port and baud rate is in the serial object. I activate the metro and send a byte. I see the RX light up on the Arduino but no data flow through the patch. I send 10 to the Arduino in the Arduino 0013 programming environment and the program runs fine using the Serial Reader in that program.
    Any suggestions?

    • Feb 12 2009 | 7:16 am
      Max & Arduino play fine together, so something isn't right in your patch or sketch. Posting your patch will get you more help. Posting your sketch might help, too. Have you had any success with the existing Max-Arduino patches & sketches, e.g. "Arduino2Max" patches & sketch?
    • Feb 12 2009 | 3:45 pm
      I am using the Communications Tutorial 2: Serial Communication tutorial patch w/ the sample code provided. None of the third party objects like Arduino2Max work either, thus leading me to believe something is up with the serial object.
      Posted the code here:
      // Arduino Serial Tester // rld, cycling'74, 3.2008
      long randomvalue = 0; // random value long countervalue = 0; // counter value int serialvalue; // value for serial input int started = 0; // flag for whether we've received serial yet
      void setup() { Serial.begin(9600); // open the arduino serial port }
      void loop() { if(Serial.available()) // check to see if there's serial data in the buffer { serialvalue =; // read a byte of serial data started = 1; // set the started flag to on } if(started) { // loop once serial data has been received randomvalue = random(1000); // pick a new random number Serial.print(countervalue); // print the counter Serial.print(" "); // print a space Serial.print(randomvalue); // print the random value Serial.print(" "); // print a space Serial.print(serialvalue); // echo the received serial value Serial.println(); // print a line-feed countervalue = (countervalue+1)%1000; // increment the counter delay(100); // pause } }
      Max Code:
    • Feb 12 2009 | 4:09 pm
      Edit - Copy Compressed
    • Feb 12 2009 | 4:14 pm
      A couple things.
      *Make sure you don't have the Arduino's serial monitor open at the same time as Max. *Make sure you're talking on the right serial port. *On the newer Arduinos (Decimillias and later), when a serial connection opens, you'll need want to wait a few seconds before sending any information. This is because of the reset feature that was built into the bootloader on these versions. It's looking for information from the Arduino IDE.
      Also, use Copy Compressed when posting patches to the list.
    • Feb 12 2009 | 5:10 pm
      So I've tried everything listed here. The Arduino Programming environment isn't open at the same time Max 5 is. I triple checked the serial port is set to "a" which is my USB serial bus. I waited 10 seconds after resetting the Arduino before activating the metro and sending the byte 10 to the board. RX lights up when I send bytes, but TX does not indicating that something in the transmission back to Max is funky.
      Thanks for the advice, Steve
      Whoops, heres the Max code (edit -> Copy Compressed):
    • Feb 12 2009 | 5:54 pm
      I attempted the same basic patch in Max 4.6 and get the same results, no communication from the Arduino to Max.
    • Feb 12 2009 | 6:21 pm
      Have you tried just sending information?
      ////Arduino :: simple serial sender
      byte num = 2; void setup() { Serial.begin(9600); } void loop() { Serial.print(num, BYTE); delay(30); }
      ////Max :: simple serial listener
    • Feb 12 2009 | 6:33 pm
      does it work if you set the port by its name instead of its letter?
      see attached patch, which also provides the menu selection of available ports...
    • Feb 12 2009 | 6:57 pm
      No help there either. I hooked the umenu up, no dice, I attempted the simple serial patch, I can send bytes to the Arduino (as indicated by RX lighting up, but TX does not return values to Max). The Max Serial Communication example worked briefly last night. These programs work in the Arduino Environment Serial Monitor.
    • Feb 12 2009 | 7:26 pm
      what about other programs?
      Processing, Pure Data, etc.?
      On Thu, Feb 12, 2009 at 1:57 PM, Steve Belovarich wrote: > > No help there either. I hooked the umenu up, no dice, I attempted the simple serial patch, I can send bytes to the Arduino (as indicated by RX lighting up, but TX does not return values to Max). The Max Serial Communication example worked briefly last night. These programs work in the Arduino Environment Serial Monitor. > > Arrrgggg. >
    • Feb 12 2009 | 11:08 pm
      I haven't tried other programs, but they won't help in the context I need to present this lesson in. Thanks for the suggestion.
    • Feb 13 2009 | 12:24 am
      Hey Stephen, Everything works over here. One thing you might need to do, however, is hit the reset button on your Arduino after making the connection in Max. I don't have the Duemilanove, but have the Diecimila and have to do this. I forget why...and don't recall how you get around this. I usually use an Arduino Pro Mini and don't have to do this. Anyway, see if that helps.
      Also just a side note: you have a "zl group 1000" in your patch that will actually truncate your list at 256 elements (not that you will ever reach this limit...but still). If you want to work with lists > 256, you need to add an argument to zl, e.g. zl 1000 group 1000".
    • Mar 14 2009 | 3:20 am
      I suggest downloading Pduino for max-arduino software interfacing.
      There is a procedure you have to go through to get your Duema-whatever board working. Open the Arduino_Test patch. 1) Select the serial port from the umenu
      2) RESET the board
      3) go about your business setting pins etc.
      Took me a while to figure this out but it works like a charm.
      Best, Max
      PS this might not be available for Max 5
    • Mar 14 2009 | 10:27 pm
      here you can find a usefull link for step by step arduino-set up set up . works for max5 and uses an updated version of Firmata. hope it helps :
    • Jul 02 2009 | 5:33 am
      Hello, I'm was the getting the same (lack of) results that Stephen was reporting below. However, upon taking the suggestion of resetting the Arduino (thanks, David): blinky blinky!
      To be specific about my setup:
      Running the Arduino sketch and Max patch including with Arduino v. 16.
      It might be good to update the documentation of that patch to mention the reset button trick.
      Cheers, Michael
    • Jul 02 2009 | 11:58 am
      It is awefully nice that usually an arduino reset is not required when a computer running OS X boots and loads a Max patch automatically on start up (with every USB periferal already connnected). This has saved me from having to build an external reset button on an installation that is currently being shown in a gallery.
    • Sep 07 2010 | 2:20 pm
      I have tried all the max and arduio objects ( patches) and they work for fine. important to remember is to check the baud rate, as the port identification. how ever I have a small issue , all of patches read dada from any analog pin even if there is nothing attach to it. so seems like lots of noise comes from arduino. the data-noise has the same values as if a sensor is attach to it. any body has this problem tooo. thank you.
    • Sep 07 2010 | 9:22 pm
      Hi all as I have reported that max and arduino do work . after hrs of testing I did find out the the max msp stop woking with arduino. it seems like there is a serial overflow, do you guys have any idea how to do a serial flush in max msp.
      so will prevent the crash of serial ports.
      I am running mac snow leapard and max 5 with a duemilanove.
      thank you.