I need to separete every line Arduino is sending in e single value to elaborate separatly.
From Node-Red I write this function:
var output = msg.payload.split("\t");
var velimp = parseInt(output[1]);
var angle = parseInt(output[2]);
var vel = parseInt(output[3]);
var msg1 = {payload : velimp};
var msg1 = {payload : angle};
var msg1 = {payload : vel};
return [msg1, msg2, msg3];
Sorry my mistake is very stupid.
I rewritten the code and it's all ok.
Thi is new code:
var output = msg.payload.split("\t");
var velimp = parseInt(output[0]);
var angle = parseInt(output[1]);
var vel = parseInt(output[2]);
var msg1 = {payload : velimp};
var msg2 = {payload : angle};
var msg3 = {payload : vel};
return [msg1, msg2, msg3];
Last question:
It' possible to do get same results with split function?
When programming there are almost always multiple ways of achieving a result. You could use regular expressions here for example. However the clue is in your question. You ask how to split the data up so it is likely that a function called split that splits the data up is likely to be a good match.