-
Notifications
You must be signed in to change notification settings - Fork 12
PoEPi WS2812 Driving RBG LEDs
This guide will show you how to install the necessary packages on your Raspberry Pi Zero and control WS2812 LEDs using the PoEPi board. This board connects on top of your Raspberry Pi and can provide power to the LEDs and the Raspberry Pi through a POE injected line.
First you will need to install some packages before we start controlling the WS2812s. Open up a terminal on a Raspberry Pi with an Internet connection and lets get started.
First we need to grab the packages that will be used to control the LEDs. In this case these packages will come from Github where they are developed by a large community of developers. You can download these files as a .zip package but in this case we will clone them using git.
git clone https://github.com/richardghirst/rpi_ws281x
Now we need to browse into this directory in our terminal and run the installation process. This will take some time as the installer will have to download several required packages.
cd rpi_ws281x/python
sudo python setup.py install
If everything ran correctly you will be ready to start programming your LEDs. But first we need to wire them up. This is the easy part as the PoEPi board already has everything on it required. All we need to do is wire the three wires from the LED strip to the PoEPi module.
**Before connecting anything be sure to power down and disconnect the PoEPi module from the Raspberry Pi
Make sure that you are connecting the Ground wire and the 5V wire correctly, connecting these backwards could damage the LEDs. Before you connect your Raspberry Pi to the PoePi power the module with an injected Ethernet Line. The LEDs should power up and the may flicker a bit. If not that is okay. Now you can connect your Raspberry Pi and you should see it boot up.
We are going to do all of the programming through a terminal. The PoePi is designed to work over a network and in many cases without a monitor hopefully you can SSH into your Raspberry Pi. If not you can travel to this guide. First we want to open up a new text file anywhere.
nano blink.py
Then we are going to enter some code to make the LEDs do a bunch of cool things. The code can be entered in the Nano text editor and then it will be explained below.
import time
from neopixel import *
# WS2812 Config
LED_COUNT = 16 # Number of WS2812s connected
LED_PIN = 4 # The pin connected to the WS2812s on the Raspberry Pi
LED_FREQ_HZ = 800000
LED_DMA = 5
LED_BRIGHTNESS = 255
LED_INVERT = False