Recently, I learned that, there are RGB LEDs called NeoPixels with a kind of one wire interface built-in to change the colour of the LED by providing a specific clock signal. I quickly ordered a strip of 8 LED to try it out from ebay. I received it very quickly and the model number mentioned in the PCB is "CJMCU-2812-8".
As I was working with my Raspberry Pi 3 running Raspbian Stretch Lite for some other project, I wanted to test my NeoPixels with the same. After a bit of online research, I found out that many people have used level convertors to convert 3.3V logic of RPi3 to 5V logic of NeoPixels. Any how I wanted to try out the direct connection without any logic conversion with below options.
1. Powering up NeoPixels with 3.3V, so that the logic level will be the same as RPi3. Some posts from internet suggested that brightness will be reduced. As per my observation it is negligible.
2. Powering up NeoPixels with 5V, but connect RPi3 3.3V logic directly and hope for the best. But in my test setup, it worked perfectly without any issue.
The connection between RPi3 and NeoPixel PCB was straight forward when using the RPi3 library called rpi_ws281x.
GND -> GND
GPIO 18 (PWM0) -> DIN
5V or 3.3V -> 4-7VDC
GND -> GND
RPi Pin-out courtesy of pinout.xyz
You can follow up the detailed user manual of rpi_ws281x as a guide to install and use the library with Raspbian Stretch Lite. I used below commands in order to test.
Download and install the library
[email protected]:~ $ sudo apt-get update
[email protected]:~ $ sudo apt-get install build-essential python-dev git scons swig
[email protected]:~ $ mkdir neo
[email protected]:~ $ cd neo
[email protected]:~/neo $ git clone https://github.com/jgarff/rpi_ws281x.git
[email protected]:~/neo $ cd rpi_ws281x
[email protected]:~/neo/rpi_ws281x $ scons
[email protected]:~/neo/rpi_ws281x $ cd python
[email protected]:~/neo/rpi_ws281x/python $ sudo python setup.py install
Testing with standtest.py script
[email protected]:~/neo/rpi_ws281x/python $ cd examples
[email protected]:~/neo/rpi_ws281x/python/examples $ ls
lowlevel.py multistrandtest.py neopixelclock.py SK6812_lowlevel.py SK6812_strandtest.py SK6812_white_test.py strandtest.py
[email protected]:~/neo/rpi_ws281x/python/examples $ nano strandtest.py
Change parameter as below for my 8 LED strip then CTRL+X and then Y to save:
[email protected]:~/neo/rpi_ws281x/python/examples $ sudo python strandtest.py
Press Ctrl-C to quit.
Color wipe animations.
Theater chase animations.
This is the final result of my setup running standtest.py test script.