javaraspberry-pipwmpi4j

How to control adressable RGB leds with raspberryPi in Java


I have a strip of WS2811 adressable RGB leds and I am trying to control them using my raspberry pi. I am programming in java. To access the GPIO I am using a java library called Pi4j (version 1.2; java 8). This version has built-in PWM control.

My question is the following: How can I send the data to the leds trough a GPIO pin?

(I am still a beginner when it comes to physical computing, so please be gentle)


Solution

  • I haven't used NeoPixels directly on a Pi before (though I have many times used FadeCandy which is a USB LED controller that also does some nice dithering/frame blending).

    Driving NeoPixels isn't as straight forward as plain PWM on individual LEDs.

    There's a good Adafruit RaspberryPi NeoPixel wiring/coding tutorial. The notes on wiring/power are super useful. Even though the code is in Python, it's still useful to test/run.

    Having a quick look at the pi4j documentation, while it has all the "ingredients", it doesn't have built-in support for NeoPixels. Doing a quick search I spotted the diozero library which seems to have support for NeoPixels.

    I haven't tested diozero, but it's worth giving it a go.