Sending MaxMSP data to Arduino (4 bit data)

Lisa Park's icon

I am using 2 Arduinos with MaxMSP.

1. [Arduino #1] -----> sends data to [MaxMSP]

Max Patch
Copy patch and select New From Clipboard in Max.


2.
[MaxMSP] (with thresholds and calculations) -----> [Arduino #2]
The first part is working fine. But, I am having trouble sending the data to Arduino #2 from MaxMSP.
It needs to spit out 4-byte data.

When I test with the patch below, it did not show multiple data into a string. And also it can only receive the data up to 255. But, my data is minimum 1000 and maximum up to 18000. So I am thinking that I must be missing something. The above Max Patch is Arduino #1 sending data to MaxMSP and its working. I just need to reverse this mechanism to apply it on Arduino #2, but I'm lost here.

Max Patch
Copy patch and select New From Clipboard in Max.

const int led = 13; //pin 13 for board led on uno

int value;

void setup() {
//open digital pin for board led
pinMode(led,OUTPUT);

//open the serial port for reading
Serial.begin (115200);
}

void loop() {
  //checks to see if there is information on the serial port or not

  if (Serial.available()) {
    //max is sending packets of information
    //space is a separator so we need to store each value

    value = Serial.read();

    Serial.println(value);
  }//end serial
}

----------------
Any help would be truly appreciated!

Jean-Francois Charles's icon

With a serial communication, you can communicate with ASCII codes, i.e. numbers from 0 to 255.
You could send your "4-byte" numbers as digits: for 18000, you send ASCII codes for 1 8 0 0 0.

Make sure you study the example coming with Arduino in File -> Examples -> Communication...

Lisa Park's icon

Thanks, Jean! I've looked into Serial communication.. but still troubleshooting it.

Currently, Arduino is receiving the numbers (0,1) separately like below:
0
0
1
0

I need the numbers to be sent as a line (MaxMSP splitting out 4 numbers each):
0 0 1 0
0 1 0 0
1 0 0 0

Any suggestions will be truly helpful.

Many thanks,
Liz

Source Audio's icon

little example here :

Max Patch
Copy patch and select New From Clipboard in Max.