Raspberry PI and Adafruit’s Neopixel Stick

For a project i’m working on, I had to connect a Neopixel Stick to my Raspberry PI – Although the Adafruit’s Learning Center is quite good (is really very very good), and the Neopixel Uber Guide is extensive, i could not find any information about the wiring of the Neopixel Stick.

Neopixel2 Neopixel1


  • 1x Raspberry PI
  • 1x Adafruit Neopixel Stick


The wiring of the Neopixel stick is straight forward. Connect GND (any GND of the stick – it as two)to Raspberry PI GND, DIN to any PIN, in my case, PIN 18, and 5VDC to 3.3V (click image for a bigger version)



To play with the Neopixels on the Raspberry PI, it’s necessary to install the Python Neopixel libraries – rpi_ws281x – provided by Jeremy Garff.

Follow the instructions on Adafruit’s page to install the libraries, or just execute the following commands:

Install the required software

Clone the libraries and compile them

After the successful compilation, install the Python libraries

Now, we’re ready to program a little Python

Open your favorite editor and type the following code:

The code is commented, but here’s some explaining

The colorWipe function is a standard function from the strandtest.py example from the libraries.

The nightrider function is what creates the scanner pattern.  In a foor loop, from 0 to the number of pixels we have (in one stick we have 8)

Next we use the setPixelColor function (from the libraries) to set the color of the current pixel – set by the for loop.

Next, to create the scanner effect – and since we only have 8 pixels, we only use a trail of one pixel – we dim the color of the previous pixel, creating the effect (or so I hope)

The dimColor function is a bit tricky, but easy to understand.

If you read the API for the libraries and have the curiosity to read the source code, you would see that the color is a unsigned 32-bit value (that the Color definition converts into RGB).

Using that information, we can use bitwise operators to perform the color transformations.

You can read more about bitwise operations in the Python wiki.

After that, we reverse the effect.

Between every pixel, there’s a delay, controlled by the sleep function. In this case, we’re sleeping 65ms

Here’s a video showing the result



Technobly for the dimColor function

9 Replies to “Raspberry PI and Adafruit’s Neopixel Stick

        1. It is really strange… Have you check the GPIO ? Probably it is not the same has the RPi 2 b. Check the GPIO for version 3 ! Do you have all the libraries installed ?

  1. Just got myself a NeoPixel Stick (with an AdaFruit Trinket) and the first thing I did was did a kit light! He was the best.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.