In this tutorial, we'll get some WS2812B LEDs (also known as GlowBits and NeoPixels) working with a Raspberry Pi Pico.

Transcript

I'm going to show you how to get some instant gratification using a Raspberry Pi Pico and some WS2812B LEDs. We'll copy over some example code, get these running and then have a bit of a play with it to see what we can change.

These LEDs come in lots of different shapes and sizes, often on flexible strips or as circuit board modules. You also might hear them by certain trade names like NeoPixel or GloBit. I'll be using a GloBit module today because it's guaranteed to work with 3.3V logic. You can usually get these WS2812B strips to work with 3.3V logic, but every now and again it may not work and may need some logic level conversion. We won't go into that today. Suffice to say GloBits use the latest version of these LEDs which will always work with 3.3V logic.

I'll be using some of these springy clip connectors today, but if you have pins on your Pico or a breadboard that will work really well too. Let's begin by wiring the Pico up to the LEDs. I've flipped the Pico upside down so maybe you can see the pin labels. Always a good idea to unplug your Pico from power when you're doing any wiring. I'll first make the ground connection with this black lead. So I'll pick one of the ground points on the Pico and connect that to the big ground tab on this rainbow. With my red lead I'm going to connect the bus, which is the top pin. You'll see these labels are compressed under this mounting hole. That's okay, with the latest WS2812B version 5 LEDs, they're happy to run at either 3 or 5V. And finally my yellow lead I'm going to connect to GP22. And that will connect to the data connection on the rainbow.

I'm happy that this is connected correctly so I'm going to connect my Pico to my computer. Time to fire up the Thonny editor. If you don't know what this is, check out the linked video where we set up Thonny to program.

The Pico is a great tool for creating beautiful scrolling patterns on a rainbow. To get started, I'm going to grab some example code from the article for this video and paste it into Thonny. There are two important parameters to consider: the number of LEDs and the pin number that will control the LEDs. I'm using GP22 today. After running the script, I saved it in my documents under code and called it rainbow.py.

Scrolling down in the code, there is a brightness parameter that can be adjusted between 0 and 1. There is also a lot of inline assembly code for driving the strip, as well as some useful functions for filling the whole strip with a certain color or picking a color from the color wheel. At the bottom of the code, there are color definitions in the red, green, blue color format.

I couldn't find the color orange in the list, so I went to colorhex.com and searched for orange. The RGB code for this type of orange is 255, 165, 0. I added this to the list at the end of the Python script to create the color orange.

When the script runs, a sequence of colors will fill up, including orange, but it's a blink and you miss it. To modify the script, we can comment out the for loop and start the script with pixels fill orange and then pixels show. To make sure it works, we can create an infinite loop so the script will start, define orange, fill the strip with orange, and then just stop. After running the script, we have a nice solid orange light.

This was a fun exercise with a Raspberry Pi Pico and some WS2812B LEDs. If you have any questions, feel free to start the conversation at the bottom of this article or start a thread in the Core Electronics forums. We're full-time makers and here to help. Thanks for watching.

Feedback

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.