We are getting our Blinkies Popping Off In HERE✨! Our latest UPDATED guide will demonstrate the fastest and most customizable way to have WS2812B LEDs controlled by your Raspberry Pi. Learn the simplest way to drive a small LED strip, multiple LED strips, and how to externally power a very long strip (150 Nodes).


Hey gang, Tim here at Core Electronics and this guide will demonstrate the fastest and most customizable way to have fully addressable WS2812 LED strips running on any Raspberry Pi Single Board computer. That way, you can enjoy lighting up your home exactly the way you want, so let's crack on!

In LED stands for Light Emitting Diode and that is exactly what each of these little white boxes are. More specifically, these are WS2812B's. WS2812B strips are fully addressable. The IC chips are built into each LED node, which means that each RGB LED node can display a different colour at a different intensity than its neighbouring nodes. This freedom means you decide exactly what each LED node does at any given point, with no hardware restrictions.

On the table before me is everything you are going to need. Here, I'm using a Raspberry Pi 4 Model B 2 Gigabyte, but any Raspberry Pi board can work with WS2812BS. You will also need everything to run this Raspberry Pi as a desktop computer. Naturally, we're also going to need some of those 5 volt WS2812 LED strips to control. Here, I brought two small strips which are powered directly from the Raspberry Pi and one very long WS2812B strip with 150 LED nodes on it. This big strip will require external power to drive fully.

This is the time to gauge your eyes over the optional extras which are a female DC Barrel Jack and a 5 volt 4 amp power supply. A general rule of thumb is that a quality 5 volt 4 amp power supply can comfortably handle 150 LED nodes at full brightness. These optional extras are only required if you're controlling more than approximately 30 LEDs. You're also going to want jumper cables and a small screwdriver.

We will now set up our Raspberry Pi as a desktop computer. This guide assumes you know how to flash Raspberry Pi OS onto a new microSD card. Check the description for a guide if you need. Insert that microSD card into the Raspberry Pi and power it up. setup is now complete

We are going to power a single small strip of WS2812Bs, so turn your attention to the strip and the three wires coming out of it. Also note the arrows drawn on the physical LED strip PCB; this is the direction of the data flow. Not adhering to this is a common troubleshooting issue.

Before we put power into our Raspberry Pi, let's connect up our strip of WS2812Bs. I'm going to use some jumper cables to help me. I also like to use one of our Raspberry Pi pin out cards for reference when doing this. Start by connecting the red power wire to the 5 volt pin of the Raspberry Pi, then connect the white ground wire to a ground pin on the Raspberry Pi, then connect the green data pin to GPIO18 of the Raspberry Pi. With that complete, let's power up the Raspberry Pi system by plugging in a USBC connector.

Some packages will need to be installed on your fresh version of Raspberry Pi OS. This is going to allow the correct operation of WS2812B LED strips. With the power into the system, you're going to be welcomed by the Raspberry Pi desktop. Open a new terminal window by pressing the black button on the top left of the screen. This terminal window will enable us to download from the internet the exact packages we require for this setup. From the full written up article (link to it down below in the description), find the section on software setup and copy paste and enter the three terminal commands one by one into the terminal. This is going to provide you with all the packages that you need. If ever prompted, type and enter 'y' to continue installations.

Since we have the full written up article open, also download the Python script zip file found at the very bottom of it. Unzip it to the desktop or whatever directory you deem appropriate. With that complete, the setup is now complete.

Programming packages and software to correctly power and drive WS2812Bs will now be on your hardware, so let's get some lights flashing! From here, open up a Python interface like Thonny IDE, which is just a Python interpreter software. You can use whichever is your preference for this. We're going to need a Thonny IDE which has pseudo privileges to do that. Open up a new terminal window and type into it "sudo funny" then open up the Python script named "OneStripNeopixels.py" now press the Run button and your WS2812B LED strip should spring to life!

Oh very happy! All my Python scripts are fully annotated, so let's take a quick dive into this one so I can point out some control levers that we can adjust. First, you're going to note that three lines import all our extra functionality to Python that we're going to require. Then, the very first variable is created to represent our strip named "pixels1". We can also alter some values in this line as well, like which GPIO pin will be used for our data, how many nodes are on the strip, and the overall brightness level. Brightness is decided from a zero to one value.

Then our very first command to the LED strip, "pixel1.fill", is followed by three numbers. The Fill command will make the entire strip shine a specific color. Those three numbers are the RGB color codes. The three numbers can be anything from 0 to 255. As an example, the color combination of 2550 would produce a red light. You can use an RGB color code chart website to quickly decode the RGB numbers for a desired fill color.

The very next line is another command to the LED strip which states that on our strip we want LED node 10 and only 10 to shine a different color. That is why when we see the code first run, we can see a single node showing a different color. The clarity the node at the start of the strip is zero. For this, we're going...

To need two separate LED strips to be electrically connected to our Raspberry Pi, it is good practice to turn off the Raspberry Pi before connecting and disconnecting wires from the GPIO pins. I have lost the Raspberry Pi by not doing this. Now we have the first LED strip set up exactly the same way as before. The second lower density LED strip will connect to the GPIO as follows: the red power wire will go to the other 5 volt pin on the Raspberry Pi, the white ground wire is going to go to another ground pin on the Raspberry Pi, and the green data wire is going to go to GPIO 21.

With that done, let's put power back into our system and turn our attention to the Python IDE. Open up from the unzipped file the Python script labelled “two strips neopixels.py”. In the same manner as before, double check quickly before running your script that the amount of LED nodes has been set up correctly for both LED WS2812B strips, then press the Big Green Run button. The two strands will spring to life displaying multiple different fill colors.

Jumping into the code, you can see the script is very similar to before except there are two pixel variables created that represent both the strands. Note here there are four available data wired GPIO locations on a Raspberry Pi single board computer. The GPIO pin locations are GPIO21, GPIO18, GPIO12, and GPIO10. Each can independently drive a separate WS2812B LED strip. That means by expanding on this script you can control four fully addressable WS2812B strips independently with a single Raspberry Pi single port computer.

For the final part of this guide, let's now control a really long length of WS2812B strip from a Raspberry Pi single board computer. If you want to power an entire strip, you're going to need to supply more power to the LED strip than the Raspberry Pi Power Pin outs will be able to do.

LEDs can draw a lot of electrical current, especially in long strips like this. Each pixel will draw about 20 milliamps on average and 60 milliamps when displaying white light at max brightness. Therefore, we're going to hook up a 5 volt 4 amp power supply with a DC Barrel Jack into our system. All WS2812B LEDs sold by us are going to have two white wire round connections, two red wire power connections, and one green data wire already soldered onto the end of the LED strip.

So, let's turn off our Raspberry Pi and get to connecting up our system. Using a screwdriver, connect the white wire to the negative screw down terminal of the DC Barrel Jack, then connect the red wire to the positive screw down terminal. Connecting these backwards and then powering up your LED strips are going to break your LED strips, so be sure to get this correct.

Then grab two jumper cables, you're only going to need a green and a white one. Connect the white ground wire to any ground pin on the Raspberry Pi, then connect up the green data wire to the GPIO 18 of the Raspberry Pi. Note that both the Raspberry Pi Single-Board Computer and the power supply are going to share a common ground, as all the white wires connect to each other. Without a common ground connection between these two systems, there will not be a static reference. This results in floating voltages and errors and messages sent down the LED strips.

Open up in Thonny IDE in the same manner as before, strandtest.py with the script open. Quickly double check that the LED count is reasonably correct, and then just press the Big Green Run button. Just like that, your LED strip should now be producing beautiful colors. Feel free to jump into the open source python script to see exactly what is driving these animations and lighting styles. With this as your inspiration, you're going to be lighting up the world with some custom designs.

LED patterns in no time? Naturally, there are heaps of different and already crafted Python scripts for controlling WS2812B LED strips with a Raspberry Pi single board computer. Some of the best open source Python options that I've found I've linked down in the description below. So, if you want sound reactive LEDs or an LED GUI control to create patterns for WS2812Bs, check down there.

Now, if you are interested in taking this to the next level and want to power hundreds or thousands of LED nodes, please note that there are some important standard practices to know beforehand. Check the description below for that guide.

And that is that with my flashy blinking lights dancing along gorgeously and you with all the information to do exactly the same, come get a month. We have a forum that you can contact us on if you ever run into a wall and just need that little troubleshooting boost to bounce over it. We are full-time makers and we are here to help. So, until next time, stay closer.



Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.