Basic Serial communication Arduino <> Max/MSP not working

AJREIJN's icon

Hi there,

I'm trying to get very basic serial communication going between Arduino (UNO R3) and Max/MSP (Max/MSP 8 running on MacOS Sonoma). But without any results. When I open the Serial monitor in Arduino (which I of course closed again when testing things through Max...) it works just fine, so I'm assuming the connection can't be the issue. Does anyone have an idea what I'm doing wrong here? Really hope someone will be able to assist...

Anne-Jan

int LED_pin = LED_BUILTIN;
int value1 = 300;

void setup() {
  Serial.begin(9600);
  pinMode(LED_pin, OUTPUT);
}

void loop() {
  if (Serial.available()) {
    value1 = Serial.read();
  }

  digitalWrite(LED_pin, HIGH);
  delay(value1);
  digitalWrite(LED_pin, LOW);
  delay(value1);

  Serial.println("hello");
}

HEiii_02.maxpat
Max Patch

Source Audio's icon

It is not possible that that code "works just fine "

did you try to type in arduino serial monitor a value like 1000

to change delay time ?

I guess not.

change Serial.println("hello"); to Serial.println(value1);

to see what value gets set