How To Use Addressable RGB WS2812B LED Strips With a Raspberry Pi Single Board Computer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey gang Tim here at car electronics and this guide will demonstrate the fastest and most customizable way to have fully addressable ws2812 LED strips running on any Raspberry Pi Singapore computer that way you can enjoy lighting up your home exactly the way you want so let's crack on in [Music] LED stands for light emitting diode and that is exactly what each of these little white boxes are more specifically these are ws2812bs ws2812b strips are fully addressable the IC chips are built into each LED node this means that each RGB LED node can display a different color at a different intensity than its neighboring 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 a 150 LED nodes on it this big strip will require external power to drive fully this is 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 [Music] 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 micro SD card check the description for a guide if you need insert that micro SD card flashed with Raspberry Pi OS then add a mouse keyboard and HDMI out to a monitor to start we're 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 so before we put Power into our Raspberry Pi let's connect up our strip of ws2812bs and 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 and 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 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 funny IDE is just a python interpreter software and you can use whichever is your preference for this we're going to need a funny 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 one strip neopixels.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 pixels one 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 and then our very first command to the LED strip pixel1 dot fill this command 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 [Music] 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 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 funny IDE open up from the unzipped file the python script labeled two strips neopixels dot 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 of 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 gpio 10. 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 foreign the final part of this guide let's now control a really long length of ws2812b strip from a Raspberry Pi single ball computer if you want to power an entire strip you're going to need to supply more power to the LED strip then the Raspberry Pi Power Pin outs will be able to do fully addressable ws2812b 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 connections between these two systems will not have a static reference this results in floating voltages and errors and messages sent down the LED strips open up in funny 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 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 ball 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 [Music]
Info
Channel: Core Electronics
Views: 135,159
Rating: undefined out of 5
Keywords: how to use strip LEDs with a RaspPi, ws2812, ws2812B, rgb, guide, tutorial, fully adressible, addressable, easiest way to RGB control, no diode method to powering WS2812B, NDo I need a Level Shifter to control LED Lights, no, GPIO Pins to control LED strip from Raspberry Pi, RPI, 5V WS2812B Strip, waterproof, flexible, glowbit, neopixel, rigid pcb, sound reactive in description, terminal commands to control LEDs, raspberry pi OS, 150+ LED Nodes Power, externally power LEDs, Easy, Simple, lifehack
Id: aNlaj1r7NKc
Channel Id: undefined
Length: 13min 33sec (813 seconds)
Published: Mon Oct 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.