Help with serial object

bjoerndamlarsen's icon

Hey everybody im currently doing a university project and I have to find a way how to control a LED chain from Max Msp via Arduino.

I want to send a list with 4 values from max to arduino over the serial object. The first value which will choose a specific LED and then the three other values sets the colour.

LED Nr R G B

10 0 0 255

My question is "how exactly do I pack together 4 values and send them through the serial object". I have tried a few solutions but it does not seem to work. Can I send four values into (pack 0. 0. 0. 0.) and then connect it to the serial object.. is it that easy? or do I have to use (atoi) to convert the values into ASCII before sending them to (serial a 9600).

I have never used the serial object before so im not sure how to do it!!

hope you can help :)

balam's icon

simplest way to do this is to have the arduino listen for serial events.

then just messages thru serial object, maybe not pack messages, unless you want to code the arduino to break serial strings,

balam's icon
Steven Miller's icon

I've attached a zipped Max patch, Arduino sketch, and schematic that will demonstrate sending RGB values from Max to Arduino to control an RGB LED. Let me know if you have questions.

5452.RGBLED.zip
zip