There are many ways to hook up WS281x led to a Raspberry Pi. This is how I have done it.


Items needed

Raspberry Pi 0 from Micro Center Here

5 meters of ws2812 Leds from Ali-express Here (5m 30 leds IP30)

12v 5A power supply from Ali-express Here

DCDC step down buck converter from Ali-express Here

Bread board from Ali-express Here

Jumper wires from Ali-express Here

Connecting it up

The GPIO pins being used are 5v(pin 2), GND(pin 6 and 14), GPIO18(pin12)

I start with Raspberry Pi OS lite version to keep it minimal. Download here

Then make sure all software is up to date with the following:

sudo apt update

sudo apt upgrade

I need to install the python library for the LED's

#make sure I have pip

sudo apt install python3-pip

sudo pip3 install rpi_ws281x

Taking from the example

#!/usr/bin/env python3

import time

from rpi_ws281x import PixelStrip, Color

# LED strip configuration:

LED_COUNT = 50 # Number of LED pixels.

LED_PIN = 18 # 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 = 25 # 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

# Define functions which animate LEDs in various ways.

def colorWipe(strip, color, wait_ms=0):

"""Wipe color across display a pixel at a time."""

for i in range(strip.numPixels()):

strip.setPixelColor(i, color)

# Main program logic follows:

if __name__ == '__main__':

# Create NeoPixel object with appropriate configuration.


# Intialize the library (must be called once before other functions).


colorWipe(strip, Color(255, 102, 0)) # Red wipe

Now run the test

sudo python

The result should be the leds turning red.