Forums > MaxMSP

serial object + Arduino

Jan 01 2011 | 5:32 pm

Happy 2011 to all

I am sending X-Y coordinates from a touchscreen simultaneously to Max, via Arduino*, writing my own code adapted from what I found on Practical Arduino site. Way back in the mists of time, I knew how to punctuate and unpack two simultaneous bytes in Max, but I've kinda lost my way. Can someone assist? I've attached a screenshot (apologies for this) showing the raw vals coming into Arduino, my Arduino to Max code and the Max patch. What I am looking for is two streams of values in Max, one for each axis.


*I'm not using the standard pnp chip/drivers that came with the panel cos it's REAL flaky. Using Arduino to get raw voltages.


  1. maxPunctuate.jpg


Jan 01 2011 | 6:06 pm

Thanks for looking,

used Serial.print(255, BYTE) for punctuation,
then in Max: [select 255] -> [zl group 2] -> [unpack 0 0] from
the serial object


Jan 02 2011 | 9:18 pm

xVal>>2 and yVal>>2 might also get 255, when transmitted as 8bit.
this will confuse [zl group].

The way I solved this, is to split the 10bit analog read into a high and a low byte and use two bytes (0xff) for punctuation.

void send_packet(int pin, int value)
Serial.write(byte(0xFF)); // Packet start magic
Serial.write(byte(value & 0xff)); // Lo Byte
Serial.write(byte(value >> 8)); // Hi Byte

in max i use [match 255 nn nn nn] to seperate the packets.

-- Pasted Max Patch, click to expand. --

Jan 02 2011 | 10:11 pm

Hi mudang and thanks;
The analog voltages were coming in VERY jittery (cheap Far East tech) and never attained 255, but I’ve done a little smoothing in my hardware circuit and Arduino code (via grounding resistors and forcing unused analog inputs to 0v), but if I need further stability I’ll definitely use your idea too….unfortunately there are missing objects in your patch (bang2byte?), but the concept is clear,
thanks again

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

Forums > MaxMSP