Controlling NeoPixels with the Raspberry Pi A+/B+

Addressable LEDs or NeoPixels are typically used in combination with an Arduino or similar microcontroller, due to the timing critical signal required to control them. An SBC such as the Raspberry Pi is not suited for such realtime GPIO activities, as the Linux operating system runs other tasks in parallel. Or at least that was the case until Jeremy Garff found a way to use the DMA (Direct Memory Access) module to transfer bytes of memory between different parts of the processor, without using the CPU and thus not being interrupted by the Pi’s OS.

This procedure works for all Raspberry Pi models except version 2!


Jeremy Garff has written a library called “rpi_ws281x”, which can be found on his GitHub page: It makes use of the Pi’s BCM2835’s PWM module to drive the controllable WS281X LEDs found in NeoPixel strips and rings. The folks at Adafruit have created a Python wrapper for the library along with some Python example scripts, making it look and feel like the Arduino NeoPixels library. So if you’re familiar with NeoPixels on the Arduino, you should be up and running with this version in no time.

To compile and install the library, follow the steps below.

First, install the dependencies required to download and install the library:

Next, download the files and build the library:

Finally, install the Python wrapper:

As you can see, these steps are very straightforward.


Screen+Shot+2015-05-20+at+10.29.31Hooking up the NeoPixels to the Raspberry Pi is extremely easy, just make sure the power supply used is properly rated for the number of NeoPixels you intend to use. For testing, I used a 5V/4A power supply to power the Pi and the NeoPixels (12 and 60 LEDs).

Make sure the ground signals of the NeoPixel strip/ring and the Raspberry Pi are connected. If they are not, the LEDs won’t function properly and will light up in unpredictable patterns.

Even though the LED strip/ring operates at 5V and the Pi’s GPIO at 3.3V, it appears that it is possible to drive the LEDs without having to use logic level conversion.


I tested two components:

  • an Adafruit NeoPixel ring with 12 LEDs
  • an addressable WS2811 60 LED strip from eBay

Both performed as expected using the sample script (, which I edited to configure the correct number of LEDs:

As you can see, it is also possible to edit other parameters to match the LEDs used, but also parameters such as brightness.

photo+2 photo+(7)


© Frederick Vandenbosch, 2014-2019. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.