HappiyFountain
Posts: 1
Joined: Thu Feb 07, 2019 10:24 am

Can not control full WS2801 LED Strip with RaspberryPi

Thu Feb 07, 2019 10:57 am

We are working on a Raspberry Pi (3B+) project with Python 3, where we want to play music and light a WS2801 LED strip at the same time. The problem is that we can’t get the strip to light up.
The data cables are connected to the Raspberry Pi: MOSI (SI/DI) - Pin 19, SCKL (CK/CI) – Pin 23. We have an external power supply with 5V and 6A for the LED strip and it is connected to the ground of the LED strip, which is also connected to the GND of the Rasberry Pi Pin 6.
We tried different example scripts as well as our own code. All run without error.
The only thing that happens is, that the first LED lights up white. We read in many threads that this means it is not grounded correctly. But the difference in our case is, that the first LED also reacts to given input. So if we write a script that should light up 3 times, that's what it does. Also to mention: We can not change the color of the first LED.

We read threads of similar issues, but none of the issues really matched our problem and despite that we tried every solution given.

We really don’t know what to do and would appreciate every help we can get.

Thanks in advance!

Lina, Meltem and Lea




_____________________CODE SECTION______________________________

# Simple demo of of the WS2801/SPI-like addressable RGB LED lights.
import time
import RPi.GPIO as GPIO

# Import the WS2801 module.
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI

# Configure the count of pixels:
PIXEL_COUNT = 3

# Alternatively specify a hardware SPI connection on /dev/spidev0.0:
SPI_PORT = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(PIXEL_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE), gpio=GPIO)


def blink_color(pixels, blink_times=5, wait=0.5, color=(255, 0, 0)):
for i in range(blink_times):
# blink two times, then wait
pixels.clear()
for j in range(2):
for k in range(pixels.count()):
pixels.set_pixel(k, Adafruit_WS2801.RGB_to_color(color[0], color[1], color[2]))
pixels.show()
time.sleep(0.08)
pixels.clear()
pixels.show()
time.sleep(0.08)
time.sleep(wait)


if __name__ == "__main__":
# Clear all the pixels to turn them off.
pixels.clear()
pixels.show() # Make sure to call show() after changing any pixels!

for i in range(3):
blink_color(pixels, blink_times=1, color=(255, 0, 0))
blink_color(pixels, blink_times=1, color=(0, 255, 0))
blink_color(pixels, blink_times=1, color=(0, 0, 255))

nateolson
Posts: 4
Joined: Thu Feb 14, 2019 2:29 am

Re: Can not control full WS2801 LED Strip with RaspberryPi

Mon Mar 04, 2019 12:23 am

Did you ever find a solution for this issue? I have my pi wired the exact same way, and I have also tried the same code that you pasted.

Andyroo

Re: Can not control full WS2801 LED Strip with RaspberryPi

Mon Mar 04, 2019 1:58 am

Forgive me but I do not have any of these (or a spare Pi for most of this week) so cannot check this :o but from what I can see of your code you have used 'PIXEL_COUNT = 3' but are looping around pixels.count() - my guess is that the pixels.count() is returning zero all the time hence it only lighting the first LED up. The example https://github.com/adafruit/Adafruit_Py ... pletest.py does not use the function but the PIXEL_COUNT variable so I think you code should be:

Code: Select all

# Simple demo of of the WS2801/SPI-like addressable RGB LED lights.
import time
import RPi.GPIO as GPIO

# Import the WS2801 module.
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI

# Configure the count of pixels:
PIXEL_COUNT = 3

# Alternatively specify a hardware SPI connection on /dev/spidev0.0:
SPI_PORT = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(PIXEL_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE), gpio=GPIO)


def blink_color(pixels, blink_times=5, wait=0.5, color=(255, 0, 0)):
    for i in range(blink_times):
        # blink two times, then wait
        pixels.clear()
        for j in range(2):
            for k in range(PIXEL_COUNT):
                pixels.set_pixel(k, Adafruit_WS2801.RGB_to_color(color[0], color[1], color[2]))
            pixels.show()
            time.sleep(0.08)
            pixels.clear()
            pixels.show()
            time.sleep(0.08)
        time.sleep(wait)


if __name__ == "__main__":
    # Clear all the pixels to turn them off.
    pixels.clear()
    pixels.show()  # Make sure to call show() after changing any pixels!

    for i in range(3):
        blink_color(pixels, blink_times=1, color=(255, 0, 0))
        blink_color(pixels, blink_times=1, color=(0, 255, 0))
        blink_color(pixels, blink_times=1, color=(0, 0, 255))
NOTE: You must have the ground from the LED strip connected to the ground of the Pi :)

Not sure why the colour does not change - need to read more but let me know how you get on as I'm off to bed.

Return to “Graphics, sound and multimedia”