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))