Max MSP serial communication


I just started using Arduino, so I don't know much. I have managed to piece together my first sketch to control a DC motor's speed and direction. Now I want to control the motor from Max MSP.

I have no idea how to do this. I will post what I coded for Arduino but I feel it isn't close to what I should have done:

I was wondering if anyone could direct me to a tutorial with in depth description of how to control Arduino from Max MSP. All I can find online so far is how to get information from the Arduino. A lab or something to take me through the steps as I am not at level where just discussing concepts helps.

I would start slow with Arduino but I just started using it to realize a project I already had in my head.


2nd hit in google - arduino max msp ...

Thanks for the link, I was checking out maxuino but I was curious how to do this without it.

The thing I don't understand is ...

  1. How to properly send information to the arduino, and how to even tell if it is receiving any information from max.

  2. What to write codewise for the arduino in order to distribute the information I am sending from max to the arduino. I am trying to send two numbers to the code, one to control the motor's speed and another to indicate HIGH or LOWin order to switch the direction of the motor.

What kind of code do you write to tell the arduino where to put the numbers you are sending it?

analog write controls the motor's speed so I was trying to write the code so that the first set of numbers I send from max are to control the speed.

I can type in a number from 0 to 255 and upload it to change the speed but I want to use max so I can vary the speed from the computer. My only idea was to define a variable called "thespeed" based off of the information coming from the serial port. But I don't know if the arduino is receiving any numbers from max let alone knowing what to do with them.


I found information on parsing the numbers you send in a string and I tried to use that information in my code to define the numbers the arduino is recieving but I don't know if it is close to what is the proper thing to do, I am just guessing . I did this ....

while (Serial.available() >0) {

int thespeed = Serial.parseInt();
int thedirection = Serial.parseInt();

if ( == '\n') {

thespeed = 255 - constrain(thespeed, 0, 255);
thedirection = 255 - constrain(thedirection, 0, 255);



Does this look close to right? I am looking into maxuino but if I could do this without it I'd really prefer to, just so I have more of a chance to understand how the arduino itself works.