Advanced Communication MAX & ARDUINO

ATH's icon

Hi,
I am trying to send a Max list (here 5 values) over the serial port and read it into a array in Arduino. Unfortunately without success.
Further also the recognition of strings in Arduino
and furthermore the sending of numbers and strings from Arduino to Max are also interesting to me.

Hereby the Max Patch and the Arduino Code, that I tried to use.
Can anyone help me there?

int incoming;
int incomingold;
int LED_Werte[ ] = {1, 2, 3, 4,5};

void setup() {
Serial.begin(9600);
}

void loop() {// trying to store a list from Max into an array

while (Serial.available() > 0) {
incoming = Serial.read();
}
for (int i = 1;i<=5;i++) {
incoming = Serial.read();
if (incoming != incomingold){
LED_Werte[i] = incoming;
}
}
}

/*Also wondering how to handle keywords like red green blue alpha and
store the following numbers*/

/*Also wondering how text and or numbers could be sent back to Max*//

Max_to_Arduino_Array.zip
application/zip 2.71 KB

cskonopka's icon

I researched this same thing years ago but I need to look into it again. I created a project called arduivis which may be helpful in this case. After some research I will get back to you with a better answer. The issue with reading keywords is that it won't come in as a whole word. You will need to iterate each character into a char array and know the size of the array when it enters.

Numbers are easy and I've documented this in the project mentioned above. I will research keywords to see if there is a way to streamline the process.