node-red v3.0.2
node-red-node-pi-neopixel v2.0.0.
Hi,
this is my first experience with raspberry pi, node-red and neopixels, so please be patient with me
Within my bachelor thesis i am trying to read a CAN signal and depending on the signal lighting up neopixel LED's.
The LED strip is driven by the GPIO18 of the pi and the 3,3V PWM signal is shifted to 5V by a external level shifter. The LED's are powered with a external 10Amp power supply
Reading CAN signal's and displaying them on the node-red dashboard works. I can also drive the neopixels manually via inject node.
The CAN signal i need to use delivers values between 0.0 and 100.0. I want to light up the LED's depending ond the signal value. For example a value of 24 should light up the first 24 LED's of the strip.
The current flow looks like this:
I am using the following code in the function node:
'''
var canValue = msg.payload;
var maxLeds = 100;
var progress = Math.round(Math.min(Math.max(canValue, 0), 100));
var neopixelArray = ;
for (var i = 0; i < progress; i++) {
neopixelArray.push(255, 0, 0); // Beispiel für rote LEDs
}
msg.payload = neopixelArray;
return msg;
'''
Unfortunately the LED's do not light up depending on the CAN value, debugger shows the following faults:
Could you help me out with a proper code to drive it?
Thanks a lot