WS2801 pixels can create really cool displays – for longer strips you can turn them into a matrix, or shorter ones can be used for lighting effects, visual notifications or anything you can dream up! Below is a short guide on how to use WS2801 pixels with python on a Raspberry Pi – updated March 2022 (Original Deemeber 2014). If you want an easy setup controllable via your android phone, you can install hyperion – follow the same instructions as for the BerryGlow, but start with Raspberry Pi OS!
Raspberry Pi 3B+ (any model can operate the WS2801 pixels, obviously not all have wifi)
AndyPi PixelLight Strip (WS2801)
PixelLight === Raspberry Pi
+5v === +5v (pin 2)
GND === GND (pin 6)
SI (DATA) === MOSI (GPIO10 – pin 19)
CK (CLOCK) === SCLK (GPIO11 – pin 23)
(Alternatively, if you have a long strip, you can power from a separate supply (see diagram))
1. I’m using mine headless, and used the Rapsberry Pi imager on Windows 10 to write the Raspberry Pi OS 32-bit Lite (2022-01-28). I added my wifi settings and turned on SSH. The rest of the setup was done over SSH.
2. Ensure SPI is available (it is turned off by default):
select number 3 (interface options)
then select I4 (SPI)
finally select “Yes” to enable SPI by default
3. We need to install the hardware SPI control module for python. Start by updating the system, installing git and pip if you haven’t already:
sudo apt-get update
sudo apt-get install git
sudo apt-get install python3-pip
sudo pip3 install flask
sudo pip install spidev
3. Get the basic python module for accessing the PixelLights (based on Adafruit’s work), and run the file to test (you should get a rainbow swirl by doing the following:
git clone https://github.com/andy-pi/pixellights.git
sudo python AndyPiPixelLights.py
4. You’re now ready to download the demo python file, included in the repository (PixelLightsDemo.py) to create your own projects. You can edit this to your own requirements, controlling each pixel individually, using a rainbow swirl, or a colour wipe. All the modules are imported from the file above, see the comments in the code for examples!
5. You can also check out PixelPi software, which is for image processing for matrices of pixels.