3

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)

print("Start")

pixels.fill((0,0,0))
pixels.show()

time.sleep(1)

print("loop")

while True:
    print("red")
    for i in range(0,5):
        pixels[i] = (255,0,0)
    pixels.show()
    time.sleep(1)

    print("green")
    for i in range(0,5):
        pixels[i] = (0,255,0)
    pixels.show()
    time.sleep(1)

    print("blue")
    for i in range(0,5):
        pixels[i] = (0,0,255)
    pixels.show()
    time.sleep(1)
  • How many LED’s in your strip? Are they powered from a separate power supply? – CoderMike Apr 23 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 – Thomas PomTom Steel Apr 23 at 7:38
  • 1
    Have you got a common ground between Pi and 12V power? – CoderMike Apr 23 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. – Thomas PomTom Steel Apr 23 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 – Thomas PomTom Steel Apr 23 at 9:33
3

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, privacy policy and cookie policy

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