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; // 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:
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).
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:
A Raspberry Pi web server, connected to Arduino & LEDs, serves NodeRED, flow is used to interact with Arduino from a UI controls RGB LEDs. By Sikkandar Sulaiman.
String recv = Serial.readStringUntil('\n');
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.