GPIO Output stopps on WS2812B

Hello I’m new to this Forum.
I was following the LED WS2812B Tutorial on this page: How To Use Addressable RGB WS2812B LED Strips With a Raspberry Pi Single Board Computer - YouTube

Now i have the Problem that if I’m running a script with some commands for the LED after around 40 seconds the GPIO 18 Pin stops sending any signals and the LEDs just freeze in place.

I am relativly sure its not my code since I tryed different versions of it, the last one very simple just swiches between red and blue for all LEDs in a infinite loop and that freezes too.

I also dont think its the LEDs i bought since i measured the voltage on the GPIO pin itself and it just goes down to 0 after around 40 seconds.

And now im out of ideas.
Please help.

Here my code if it helps:

#!/usr/bin/env python3

import time
from rpi_ws281x import *
import argparse

# LED strip configuration:
LED_COUNT      = 60      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 10     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53



# Main program logic follows:
if __name__ == '__main__':
    # Process arguments
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
    args = parser.parse_args()

    # Create NeoPixel object with appropriate configuration.
    strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
    # Intialize the library (must be called once before other functions).
    strip.begin()

    print ('Press Ctrl-C to quit.')
    if not args.clear:
        print('Use "-c" argument to clear LEDs on exit')

    try:
        while True:
            print("Cycle Again")

            for i in range(LED_COUNT-1):
                strip.setPixelColor(i, Color(255, 0, 0))
                strip.show()

            time.sleep(0.5)
            for i in range(LED_COUNT-1):
                strip.setPixelColor(i, Color(0, 255, 0))
                strip.show()
            time.sleep(0.5)

    except KeyboardInterrupt:
        print("exit")
        strip.setBrightness(0)
        strip.show() 

Hi Martin,

Sorry we took a bit to get a bit to this one!

Are you able to share what you see on the terminal? Do you still get your print statements in that infinite loop? i.e. does the code freeze completely or do you just not see output?

I haven’t seen this issue before, but that might help narrow it down for us :slight_smile:

Hi James,
thanks for die answer. Yes the print statements still come trough and code seem to contiue running like nothing happend.
Edit: it might also help to know if I stop the code after the LED froze in place I also get the last exit print but the Brightness doesn’t change to 0.

If I exit the code before the LED freeze the lights go out as intended.