I want to use Node-RED: inject node to send commands to Arduino, Below is the code I wrote, but it did not work. Does anyone know how to write? Thank you.
Does the code you posted run on the Arduino?
The statement if (payload = 0) looks wrong. You are assigning a value to payload, not testing the current value.
There is a Serial i/o node which sends msg.payload to the serial port. Are you using that?