Hey,
I´m struggling to get a serial in and out communication between an arduino and max msp running.
I want to use it for a motor fader.
To send data from Arduino to MaxMSP I followed the SerialCallResponse example.
Solo, the other way around, Max2Ard, works also. Using this code:
int inByte = 0; // incoming serial byte
char buffer[40];
int index = 0;
int value;
void setup()
{
Serial.begin(9600);
pinMode(11, OUTPUT);
}
void loop()
{
index = 0;
do
buffer[index] = Serial.read(); // get a byte from the serial port
if (buffer[index]!=-1) index = index+1; // -1 if no byte is present
} while (buffer[index–1] != 32); //keep collecting bytes until a space is received
value = atoi(buffer); // interpret buffer string as an integer
analogWrite(11,value); // set brightness of an LED on pin 11
}
But when I combine the codes I cant get a steady stream from the analog inputs to max msp, while being able to set the fader by sending messages from max.
Can you please hint me in a direction how to approach this ?
I hope these bits of code can reveal a problem...