I would appreciate suggestions on how to best program the function node to get a signalling lamp to respond accordingly to the analog input levels. In advance, thanks for your response.
If you use 3 outputs, what should be the on/off value that should be sent?
Something like:
const val = msg.payload;
// default value is false
const outputs = [false, false, false];
if (val >= 150 && val <=799) {
outputs[0] = true;
} else if (val >= 800 && val <= 919) {
outputs[1] = true;
} else if (val >= 920) {
outputs[2] = true;
}
// format to object with payload
return outputs.map((v) => ({ payload: v }));
the led's should go off as soon as the led colour changes, so if example the value exceeds 799, then green goes off and yellow goes on.
Thanks, I'll try your suggestion out and let you know how it went.
Thanks, just did a quick test and it seemed to work just fine, I will play with it some more tomorrow, but thanks a lot, I really appreciate your help.
It works well, thanks again
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.