This tutorial is aimed at getting some instant gratification from your WS2812 LEDs (also known as NeoPixels). We'll briefly cover a bare-bones setup for Raspberry Pi. This tutorial will work with ANY model Raspberry Pi, the Zero WH, 3B+ or 3A+ (as well as older models)!
If you've never used a Raspberry Pi before, we've got you covered with our free, online Raspberry Pi for Beginners Workshop. If you've covered at least Chapter 1 then you're ready to follow these instructions!
Parts Required for this Project
- A Raspberry Pi
- A Logic Level Converter
- Some WS2812 or NeoPixel LEDs
- A 5V Power Supply (Optional)
- A DC Barrel Jack to 2-Pin Terminal Block Adapter (Optional)
Connecting the LEDs
You will need to use an external power source, as NeoPixels take a LOT of power. Each pixel will draw about 20mA on average, and 60mA at white - max brightness. 30 Pixels will draw 600mA on average, and up to 1.8A. Ensure your power supply is large enough to drive your strip!
Here's the wiring used in the video (click for hi-res):
First, install the Python support for WS2812B LEDs:
curl -L http://coreelec.io/33 | bash
Navigate to the examples directory
Execute the strandtest script (must use sudo)
sudo python strandtest.py
That should be all there is to it! Your LEDs should be running the same pattern you see in the video.
Troubleshooting: If your LEDs only flicker erratically instead of performing a nice demo we need to make some edits to /boot/config.txt, execute:
sudo nano /boot/config.txt
and either uncomment or add the following lines:
save, reboot, and reattempt to run strandtest.py as above.
As always, if you have any troubles then reach out to us in the comments section below. We're full-time makers and we're here to help!
The one-line install command is just a simple script that automates the commands listed in Adafruit's NeoPixel tutorial. Follow the link if you want to see what's happening behind the scenes. To see the contents of the script before you run it, save it to a file with:
curl -L http://coreelec.io/33 >> ws2812-installer
Are you looking to add WS2812/NeoPixel LEDs to your other project but you aren't using a Raspberry Pi? Check out our other guides to get you started on other hardware types:
- WS2812 / NeoPixel Addressable LEDs: Arduino Quickstart Guide
- WS2812 / NeoPixel Addressable LEDs: Pycom Quickstart Guide
- WS2812 / NeoPixel Addressable LEDs: Particle Quickstart Guide
Need to take one step back and figure out what these fandangled NeoPixels even are? Check out our What Are NeoPixel LEDs Guide!