Take varying string numbers from 1-255 to control LED brightness?

I have Node-RED and an ESP32 (Arduino like WiFi module).

From a slider that the user controls, Node-RED sends string integers from 1-255.

How do I start this? I think I need to first create an array for the incoming data:

int arrayPWM[255]; // 0 to 254

Then that data needs to be converted to integers using toInt() and fed into that array?
Then, how are the integers taken from the array and fed into something like:

analogWrite(redLED, sliderVal);

I'm lost on how to connect these parts or another way on how to output 0-5 V corresponding to the raw string data (from the user controlled slider).

The serial input basics tutorial might help.

There are no end markers that terminate the string (at least I don't think). Data is continually sent... I think that's my main conundrum. What structure is needed to use data that is continuously being sent?

There has to be a way to delimit the data. Otherwise, how can you know when a data set starts and ends?

Can you post a sample of the data?

Can you control the source of the data?

Like done here:

void setup()
  pinMode(LED_BUILTIN, 1);
  pinMode(9, 1);
  pinMode(10, 1);
  pinMode(11, 1);
  pinMode(A1, 0);

void loop()
    String recv = Serial.readStringUntil('\n');
    else if(recv.substring(0,3)=="off")
    else if(recv.substring(0,3)=="tog")
    else if(recv.substring(0,3)=="pwm")

I found this recently. And now I just can’t get it to work.

OK. It works now. I don't have any LEDs with me, and was trying to use PWM on the built-in LED. Pin 13 on the Uno does not allow PWM.

It boiled down to me reading the documentation, and experimenting with substring(). Then, realizing that I was only getting high and low voltage output... because duh... it's a digital pin.

Can always leave 13 as an input, and connect a PWM pin to 13 so the on board LED can be PWM'd.