I try to control a strip led with Max msp

i send data from Max to Arduino using "serial" object in Max and Serial.read() in Arduino .
i wont to sand an array of data, one value for every single led.
So in Max i use the "pak" object before "serial" and in Arduino i do that :

#include <FastLED.h>

#define NUM_LEDS 19
#define LED_PIN 2
int b0 = 0;
int b1 = 255;

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS) ;
FastLED.setBrightness(255) ;
Serial.begin(9600) ;
}

void loop() {
if (Serial.available()){
b0 = Serial.read();
b1 = Serial.read();

leds[0] = CHSV(0, 255, b0);  //CHSV(hue, saturation, value (aka brightness))
leds[1] = CHSV(145, 255, b0);

FastLED.show();

Serial.println(b0, b1);

}

}

Problems :
1 - it work only the first Led . the second one stays on at maximum brightness
2 - if i have ArduinoIDE open together with Max. Max sand to me the error message "serial: error
opening serial port" and nothing work , Max and arduino do not communicate.

I'm nor sure what causes your issue as I do not have Max. But below some points.

Serial.available tells you how many bytes are available to read. It might very well be that there is only one byte available but you always read two bytes.

That will not print the values for b0 and b1; it will print b0 formatted according to the value of b1.

Regarding (2), only one application can make use of the serial port at a time. So close serial monitor when using Max and vice versa.

so i can't get 2 different value using serial.read() ?

You must wait till you have 2 bytes before you can do two reads; if there is only one byte available, the second read will return -1.

ok sterretje meanwhile thank you .
I want to explain my plan to you.
i want to control an entire strip led with max and arduino. so 300 led aka 300 value simultaneously.
e i need to control this value with Max. So I wanted to send every value to arduino.
And I was thinking of doing that only use serial , But after what you told me, it doesn't seem feasible to me.

So now I'm wondering if there is another method that doesn't involve wifi.

It's more than likely feasible. It's just that you don't yet know how to do it. And my problem is that I do not know what Max exactly sends but I can do the Arduino side once I know.

To (try to) solve your immediate problem with 2 LEDs

#include <FastLED.h>

#define NUM_LEDS 19
#define LED_PIN 2
int b0 = 0;
int b1 = 255;

CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(255);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() >= 2)
  {
    b0 = Serial.read();
    b1 = Serial.read();

    leds[0] = CHSV(0, 255, b0);  //CHSV(hue, saturation, value (aka brightness))
    leds[1] = CHSV(145, 255, b1);

    FastLED.show();

    Serial.print(F("b0 = "));
    Serial.println(b0);
    Serial.print(F("b1 = "));
    Serial.println(b1);
  }
}

This is not how one would normally read serial but it would be a start to see if the two LEDs do what you want them to do.

What is the hardware that you have?

  1. An Arduino. Which one?
  2. Do you have a second Arduino or a TTL-to-USB converter cable? That can be used to communicate with another terminal program; Max will still be on the USB port of your Arduino.
  3. A number of LEDs / LED strips; no need to mention that :wink:

For me to learn Max, can you post a screenshot as well as the configuration (I think it's called a patch)? Keep it as simple as possible, I only need to know the part that is relevant for this topic.

If the previous code does not give the desired result, we need to figure out what MaxMSP exactly sends. The below sketch can help; the only thing it does is count the received bytes and display it with the built-in LED. Note that I changed the baudrate to 115200 so you need to adjust eithe the below code or the MaxMSP configuration.

#include <FastLED.h>

#define NUM_LEDS 19
#define LED_PIN 2

const uint8_t pinLed = LED_BUILTIN;

CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(255);
  Serial.begin(115200);

  pinMode(pinLed, OUTPUT);
  digitalWrite(pinLed, LOW);
}

void loop()
{
  static uint16_t counter;
  static uint32_t timeoutStarttime;
  static bool rcvInProgress = false;

  // if something was received and a timeout happened
  if (rcvInProgress == true && millis() - timeoutStarttime >= 2000)
  {
    // flash count times
    for (uint16_t cnt = 0; cnt < counter; cnt++)
    {
      digitalWrite(pinLed, HIGH);
      delay(500);
      digitalWrite(pinLed, LOW);
      delay(500);
    }

    // reset variables
    rcvInProgress = false;
    counter = 0;
  }

  // if data is received
  if (Serial.available())
  {
    // read and ignore
    Serial.read();
    // update counter
    counter++;
    // update start time for timeout
    timeoutStarttime = millis();
    // indicate that receive is in progress
    rcvInProgress = true;
  }
}

You can add a serial println to send the value of the counter back to MaxMSP and display it there (no idea how that works at the MaxMSP side, I'll leave that up to you).

  1. Configure MaxMSP to send one zero. After 2 seconds, how many times does the LED flash?
  2. Configure MaxMSP to send one 2 digit number (e.g. 12). After 2 seconds, how many times does the LED flash?
  3. Configure MaxMSP to send one 3 digit number (e.g. 255). After 2 seconds, how many times does the LED flash?
  4. Configure MaxMSP to send two 1 digit numbers (e.g. 5 and 7). After 2 seconds, how many times does the LED flash?

How the above code works

  1. static variables are remembered between calls of the function (loop() in this case).
  2. If data is received (this is the second part of loop()), it is read (and ignored), a flag rcvInProgress is set and a counter is incremented. The time that a byte is received , the time is recorded in timeoutStarttime.
  3. If no extra bytes were received in 2 seconds after the last byte was received, the counter will be displayed using the built-in LED and the variables will be cleared for the next time that you send something.

The below code would be a better way; it assumes that a value for a LED is a single byte. It follows the previous approach with the counter.

#include <FastLED.h>

#define NUM_LEDS 19
#define LED_PIN 2

CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(255);
  Serial.begin(115200);
}

void loop()
{
  // index indicating which led the data is for
  static uint16_t index;
  // time that lastb byte was received
  static uint32_t timeoutStarttime;
  // indicate if we are receiving
  static bool rcvInProgress = false;

  // check if we need to update the strip
  if (rcvInProgress == true && (index == NUM_LEDS || millis() - timeoutStarttime >= 2000))
  {
    // reset variables
    index = 0;
    rcvInProgress = false;

    Serial.println(F("Updating strip"));
    // update the strip
    FastLED.show();
  }

  // check if there is something to read
  if (Serial.available())
  {
    // read a byte
    uint8_t value = Serial.read();

    // debug
    Serial.print(F("received: "));
    Serial.println(value);

    // reset the start time for the timeout
    timeoutStarttime = millis();
    // indicate that receive is in progress
    rcvInProgress = true;

    // set the value for the LED
    leds[index++] = CHSV(0, 255, value);  //CHSV(hue, saturation, value (aka brightness))
  }
}

How it works

  1. If a byte is received (second part ofloop()),
    a) The received value is used to set the CHSV value of the LED indicated by index
    b) Index is incremented
    c) The time that the byte was received is recorded for timeout purposes
    d) A flag is set to indicate that we're now receiving data
  2. If one byte was received, we check if we have received all bytes or if a timeout has occured (first part of loop())
  3. If (2) is true
    a) Reset the variables so we can received another set of data.
    b) Update the strip.

So the strip will be updated

  1. 2 seconds after the last byte was received if MaxMSP sends less that 19 bytes.
  2. immediately after the 19th byte was received if maxMSP did send 19 bytes.

Note:
this is just an example.

Ok i try your code with the second one nothing happens, with every scenary , so one-zero; 1/2/3 digit number .

With the third all first 19 leds torn on red, but one every 5 leds one is off, and if i change the input value from Max for every number i change it move back one step.
So if the led off is the N. 4 when i change the input become off the N. 3.

Now my hardwere is an Arduino UNO Rev3.

I can try to create a synchronized system that in Arduino successively controls the values of each led , and in max that sends the values of each led in succession.
But since the leds I need to control are about 300 there might be some delay

#include <FastLED.h>

#define NUM_LEDS 3
#define LED_PIN 2

CRGB leds[NUM_LEDS];

int index ;
int value ;

void setup()
{
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(255);
Serial.begin(115200);
}

void loop()
{

if (Serial.available() && (index > NUM_LEDS))
{

index = 0;

}

else if (Serial.available() && (index <= NUM_LEDS))
{

value = Serial.read();

leds[index] = CHSV(0, 255, value);

FastLED.show();

index = index + 1 ;

Serial.println(value) ;

}
}

this is what i wrote but it don't work vary well.
not usable

First things first.

  1. I do not know what you use to post code in a post on the forum, but please use code tags. It's the </> button above the reply text box.
    https://aws1.discourse-cdn.com/arduino/original/4X/7/6/0/76068b67427cb74e7360e74c52e2dd4455071975.png
  2. Can you post your saved patch; it will probably look like the patch below.

I have installed MaxMSP 8.5.1; still pre-trial so I can't save. I found SerialReadMaxMSP \ Learning \ Wiring which contains a MaxMSP patch to send H or L. I've adjusted it by changing the two boxes relating to the serial port (port h and serial h 115200 in below); you probably know how to change it in the patch itself, I haven't quite figured it out yet :frowning: Feel free to teach me :wink:

Please note that I'm not familiar with MaxMSP so I can't exlain everything in the patch.

{
  "boxes" : [     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "atoi function to convert the characters H or L to integer befor sending them",
        "patching_rect" : [ 209.0, 283.0, 405.0, 20.0 ],
        "id" : "obj-27",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "toggle to blink the LED every second",
        "linecount" : 3,
        "patching_rect" : [ 26.0, 12.0, 93.0, 48.0 ],
        "id" : "obj-26",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "toggle to send an H or an L to turn On or OFF the LED",
        "linecount" : 4,
        "patching_rect" : [ 147.0, 68.0, 93.0, 62.0 ],
        "id" : "obj-25",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "toggle",
        "patching_rect" : [ 113.0, 69.0, 20.0, 20.0 ],
        "id" : "obj-24",
        "numinlets" : 1,
        "numoutlets" : 1,
        "outlettype" : [ "int" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "newobj",
        "text" : "atoi",
        "patching_rect" : [ 112.0, 290.0, 46.0, 20.0 ],
        "id" : "obj-23",
        "fontname" : "Arial",
        "numinlets" : 3,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "list" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "message",
        "text" : "H",
        "patching_rect" : [ 156.0, 252.0, 32.5, 18.0 ],
        "id" : "obj-22",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "message",
        "text" : "L",
        "patching_rect" : [ 112.0, 252.0, 32.5, 18.0 ],
        "id" : "obj-19",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "newobj",
        "text" : "select 0 1",
        "patching_rect" : [ 113.0, 220.0, 62.0, 20.0 ],
        "id" : "obj-14",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 3,
        "fontsize" : 12.0,
        "outlettype" : [ "bang", "bang", "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "toggle",
        "patching_rect" : [ 26.0, 69.0, 20.0, 20.0 ],
        "id" : "obj-13",
        "numinlets" : 1,
        "numoutlets" : 1,
        "outlettype" : [ "int" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "toggle",
        "patching_rect" : [ 25.0, 139.0, 20.0, 20.0 ],
        "id" : "obj-12",
        "numinlets" : 1,
        "numoutlets" : 1,
        "outlettype" : [ "int" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "newobj",
        "text" : "metro 1000",
        "patching_rect" : [ 25.0, 104.0, 71.0, 20.0 ],
        "id" : "obj-6",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "bang" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "toggle object to open/close the serial and start/stop the patch",
        "linecount" : 3,
        "patching_rect" : [ 196.0, 12.0, 150.0, 48.0 ],
        "id" : "obj-18",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "toggle",
        "patching_rect" : [ 166.0, 28.0, 20.0, 20.0 ],
        "id" : "obj-17",
        "numinlets" : 1,
        "numoutlets" : 1,
        "outlettype" : [ "int" ],
        "bgcolor" : [ 1.0, 0.337255, 0.619608, 1.0 ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "select object with two options, to trigger messages, close and port ",
        "linecount" : 2,
        "patching_rect" : [ 315.0, 148.0, 227.0, 34.0 ],
        "id" : "obj-16",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "newobj",
        "text" : "select 0 1",
        "patching_rect" : [ 222.0, 153.0, 62.0, 20.0 ],
        "id" : "obj-15",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 3,
        "fontsize" : 12.0,
        "outlettype" : [ "bang", "bang", "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "The serial object, port at 9600bps",
        "patching_rect" : [ 209.0, 354.0, 188.0, 20.0 ],
        "id" : "obj-11",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "message",
        "text" : "close",
        "patching_rect" : [ 251.0, 252.0, 39.0, 18.0 ],
        "id" : "obj-10",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "comment",
        "text" : "add some message boxes and type their names for the basic communication, \"print\" (will print a list of serial ports), \"port a\" (to open the serial port) and \"close\" to close the serial port",
        "linecount" : 6,
        "patching_rect" : [ 315.0, 190.0, 175.0, 89.0 ],
        "id" : "obj-9",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 0,
        "fontsize" : 12.0
      }

    }
,     {
      "box" :       {
        "maxclass" : "message",
        "text" : "print",
        "patching_rect" : [ 251.0, 190.0, 34.0, 18.0 ],
        "id" : "obj-8",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "message",
        "text" : "port h",
        "patching_rect" : [ 251.0, 220.0, 41.0, 18.0 ],
        "id" : "obj-7",
        "fontname" : "Arial",
        "numinlets" : 2,
        "numoutlets" : 1,
        "fontsize" : 12.0,
        "outlettype" : [ "" ]
      }

    }
,     {
      "box" :       {
        "maxclass" : "newobj",
        "text" : "serial h 115200",
        "patching_rect" : [ 112.0, 354.0, 79.0, 20.0 ],
        "id" : "obj-4",
        "fontname" : "Arial",
        "numinlets" : 1,
        "numoutlets" : 2,
        "fontsize" : 12.0,
        "outlettype" : [ "int", "" ]
      }

    }
 ],
  "lines" : [     {
      "patchline" :       {
        "source" : [ "obj-17", 0 ],
        "destination" : [ "obj-15", 0 ],
        "hidden" : 0,
        "midpoints" : [ 175.5, 63.0, 249.0, 63.0, 249.0, 147.0, 231.5, 147.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-23", 0 ],
        "destination" : [ "obj-4", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-19", 0 ],
        "destination" : [ "obj-23", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-22", 0 ],
        "destination" : [ "obj-23", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-14", 0 ],
        "destination" : [ "obj-19", 0 ],
        "hidden" : 0,
        "midpoints" : [ 122.5, 240.0, 121.5, 240.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-14", 1 ],
        "destination" : [ "obj-22", 0 ],
        "hidden" : 0,
        "midpoints" : [ 144.0, 249.0, 165.5, 249.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-24", 0 ],
        "destination" : [ "obj-14", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-12", 0 ],
        "destination" : [ "obj-14", 0 ],
        "hidden" : 0,
        "midpoints" : [ 34.5, 207.0, 122.5, 207.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-6", 0 ],
        "destination" : [ "obj-12", 0 ],
        "hidden" : 0,
        "midpoints" : [ 34.5, 126.0, 34.5, 126.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-13", 0 ],
        "destination" : [ "obj-6", 0 ],
        "hidden" : 0,
        "midpoints" : [ 35.5, 90.0, 34.5, 90.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-8", 0 ],
        "destination" : [ "obj-4", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-7", 0 ],
        "destination" : [ "obj-4", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-10", 0 ],
        "destination" : [ "obj-4", 0 ],
        "hidden" : 0,
        "midpoints" : [  ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-15", 1 ],
        "destination" : [ "obj-7", 0 ],
        "hidden" : 0,
        "midpoints" : [ 253.0, 186.0, 246.0, 186.0, 246.0, 213.0, 260.5, 213.0 ]
      }

    }
,     {
      "patchline" :       {
        "source" : [ "obj-15", 0 ],
        "destination" : [ "obj-10", 0 ],
        "hidden" : 0,
        "midpoints" : [ 231.5, 249.0, 260.5, 249.0 ]
      }

    }
 ]
}

If you want to test it, copy the above (modified if needed) and paste it in a new patch. I have used the above patch to test the counter sketch (post #7) and it works as expected; if I click the H or the L box e.g. 3 times (each click within within 2 seconds of the previous one), I will get 3 flashes of the L LED on the Uno two seconds later.

This is what it looks like

Regarding your patch, I'm not sure how it is supposted to work; again, I know nothing about MaxMSP. But some comments

  1. The counter sketch times out after 2 seconds and will flash the L LED on the board based on the number of received bytes. Your metro is set for 100 milliseconds so as far as i understand it data will be send every 100 milliseconds; as a result the counter sketch will never time out and the LED will not flash. For testing purposes, change the metro in your patch to 10000 so it will only send every 10 seconds; this will make your counting of the flashes of the L LED easier.
  2. For now, I would not use a metro but simply a button to send the data to the counter sketch.
  3. I see that you have some additional boxes after the box serial f 115200 (compared to the patch above); is that to display data that is received from the Arduino?

That's it for now; I'm going to study how I can display results in MaxMSP that are received from the Arduino.

OK, I think that you need metro to regularly read the serial port.

I have modified the patch (only in MaxMSP) to below and can now see what MaxMSP receives from the Arduino with the sketch from post#7 (serial print added to send count variable from Arduino to MaxMSP) .


You can now see what is received (see e.g. https://www.asciitable.com/)
raw 52 is a count of 4
raw 13 is a (carriage return)
raw 10 is a (linefeed)

If you also connect the print box as shown in below, you can see how many bytes were received and what was sent.

The updated sketch from post#7 with the added Serial.println().

#include <FastLED.h>

#define NUM_LEDS 19
#define LED_PIN 2

const uint8_t pinLed = LED_BUILTIN;

CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(255);
  Serial.begin(115200);

  pinMode(pinLed, OUTPUT);
  digitalWrite(pinLed, LOW);
}

void loop()
{
  static uint16_t counter;
  static uint32_t timeoutStarttime;
  static bool rcvInProgress = false;

  // if something was received and a timeout happened
  if (rcvInProgress == true && millis() - timeoutStarttime >= 2000)
  {
    // flash count times
    for (uint16_t cnt = 0; cnt < counter; cnt++)
    {
      digitalWrite(pinLed, HIGH);
      delay(500);
      digitalWrite(pinLed, LOW);
      delay(500);
    }

    Serial.println(counter);

    // reset variables
    rcvInProgress = false;
    counter = 0;
  }

  // if data is received
  if (Serial.available())
  {
    // read and ignore
    Serial.read();
    // update counter
    counter++;
    // update start time for timeout
    timeoutStarttime = millis();
    // indicate that receive is in progress
    rcvInProgress = true;
  }
}

// The below was supposed to be a new post but it was blocked by the forum
Now, with the fact that I'm a little further in printing data from the Arduino in MaxMSP, I can use the MaxMSP patch in the first screenshot in post #12 and below sketch to see what MaxMSP sends. The sketch simply echoes what is received.

void setup()
{
  Serial.begin(115200);
  Serial.println(F("MaxMSP echo receiver"));
}

void loop()
{
  if (Serial.available())
  {
    byte b = Serial.read();
    Serial.write(b);
  }
}

The output in MaxMSP after you upload the sketch and connect in the indicated MaxMSP patch will be

If you look up the raw data in an ascii table (see earlier link), you will see that the first part is the text MaxMSP echo receiver (that comes from the sketch). I'm not quite sure about the last 2 bytes (240); the may come from MaxMSP but I suspect that it's related to IDE 2.0 that I used for this; I will try to check it later.

Edit 2022/12/01: The 240 comes from the 16U2 when the serial port is opened. It does not come from MaxMSP and is not related to the IDE.

If you now click H or L in the patch, it will give raw 72 or raw 76.

Now I would like you to use the above sketch and modify your patch to use print raw and show what the typical raw output looks like; I'm not sure if you can easily copy it to a text file.