I have a ws2811 LED strip that I was powering using an arduino, but I want to do some more complicated things with it, and figured my old raspberry pi would be perfect. So I followed a tutorial online and got it working... sort of ( https://thepihut.com/blogs/raspberry-pi-tutorials/using-neopixels-with-the-raspberry-pi )

I have a simple python script that should loop though red green and blue every second, but when I run it, the code works fine (prints every second) but the strip seems to hang randomly, then start working again, or display half a color, just random glitches.

Im assuming it's something to do with the data out of the pi not being what the strip is expecting, Does anyone have any ideas on this?

import time
import board
import neopixel

pixel_pin = board.D18
num_pixels = 5
ORDER = neopixel.GRB
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.2, auto_write=False, pixel_order=ORDER)





while True:
    for i in range(0,5):
        pixels[i] = (255,0,0)

    for i in range(0,5):
        pixels[i] = (0,255,0)

    for i in range(0,5):
        pixels[i] = (0,0,255)
  • How many LED’s in your strip? Are they powered from a separate power supply?
    – CoderMike
    Apr 23, 2019 at 6:36
  • currently using 5 leds (well its 45, but they are in blocks of 3, so software wise its 5) And yes running off separate 12v power Apr 23, 2019 at 7:38
  • 1
    Have you got a common ground between Pi and 12V power?
    – CoderMike
    Apr 23, 2019 at 7:54
  • I do not... that is a good thought, I did when working on arduino, but not on the pi Will give that a go. Apr 23, 2019 at 9:19
  • Yep, that seems to have fixed it Will add the rest of m code int he morning and see how it handles that Apr 23, 2019 at 9:33

1 Answer 1


Make sure you have a common ground between the Pi, the LEDs and the power supply so that referenced voltages are consistent.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.