This guide for the GlowBit 1x8 Stick will have you up and running on either a Raspberry Pi or Raspberry Pi Pico (the experience is the same), and introduce you to some useful python code examples to display both static colours and animations.

Transcript

Hello and welcome to the guide video for the GlowBit Stick 1x8 module. To follow along, you're going to need the GlowBit Stick 1x8, either a Raspberry Pi or a Raspberry Pi Pico, and some connection wires. Let's get started.

Out of the box, the GlowBit Stick does not come with any pin headers or wires soldered to it, so the first thing you're going to need to do is solder something on. You can solder a 4-pin header to the long edge, like so, or you can solder a 3-pin header to the short edge, it's really up to you.

To connect the GlowBit Stick to either a Raspberry Pi or Raspberry Pi Pico, you're going to need three wires. We're going to be using a red wire for our power or VCC connection, a white wire for the data in connection, and a black wire for the ground connection.

We'll start with showing you how to wire the GlowBit Stick to a Raspberry Pi. Firstly, the VCC connection, or power supply connection, will go to the pin labelled as a plus on the GlowBit Stick, and this can go to either the 3.3 or a 5-volt pin on the Raspberry Pi. We'll start with the 5-volt pin, just in the top right there.

The next connection we'll do is the ground connection, that will go to the minus pin on the GlowBit Stick, and the easiest ground connection on the Raspberry Pi pin header would be the third down from the top on the right side, will go there.

The last connection, the data in connection, will grab our white wire and go from the DIN pin or the DI pin on the GlowBit Stick, and it needs to go to GPIO 18 on the Raspberry Pi. This happens to be the sixth pin down on our pin header. One, two, three, four, five, six.

When setting up the GlowBit library on a Raspberry Pi, the most crucial thing to know is that you must run Thonny as root. To do this, click the terminal icon, type in sudo thonny, and we now have Thonny running as root. If you don't have this,Menu up here, there'll be a little link on the right side here. You click that, restart Thonny, and the menu should appear.

To install the libraries, you click Tools, Manage Packages. Now there are two libraries we need to install. The first one is called rpi-ws281x. This one here is the userspace Raspberry Pi library for the ws281x LEDs. The GloBits use ws2812b LEDs, so we need to install this library. Next, we need to install the GlowBit library. Type in GloBit, click Search on PiPy, and there's the first result. We click GloBit, click Install, and the library is now installed. To make sure the GlowBit library has been installed correctly, we'll type in import GloBit, press Enter, and if we don't get any error messages, we're good to go.

For the connections on the Raspberry Pi Pico, we're just going to use a breadboard to keep things nice and neat. We'll put the Raspberry Pi Pico at one end of the breadboard, like so, and then we can take our GlowBit stick and put it somewhere on the right side here so it doesn't have any existing connections to the Raspberry Pi Pico.

Making the same connections as before on the Raspberry Pi Pico, we'll take our red wire for VCC, and we'll take the power from what's called the VBUS pin at the top left here. Basically, this just connects directly to the USB input power. This will then go to the positive pin, the plus pin on the GlowBit stick, which is on the right side there. Next, we'll take our ground wire, so the easiest ground pin on the Raspberry Pi Pico would be the third pin in from the left-hand edge, and we'll connect this to the negative pin on the GlowBit stick. Lastly, we'll take our white wire and go from the DI, the data in pin, on the GlowBit stick, and connect this to pin 18 on the Raspberry Pi Pico.

Pin 18 on the Raspberry Pi Pico happens to be the fourth in from this upper right.Edge here. One, two, three, four. We'll plug that in there.

For the rest of this guide, we'll run all the examples on the Raspberry Pi Pico setup. Last thing you'll need to do then is plug in your Raspberry Pi Pico to the USB in your PC and then open Thonny. If you haven't used Thonny with the Raspberry Pi Pico before, you can check out our guide on that.

With Thonny open and your Raspberry Pi Pico plugged in, the first thing you're going to need to do is install the GlowBit library. To do this, with Thonny open, we'll click on Tools and then Manage Packages and do a search for GlowBit. Searching on PiPi, we'll find the GlowBit result there, click the link, click Install, and then wait for the GlowBit library to be copied onto the Raspberry Pi Pico.

Once the library has been successfully installed, you should see this lib folder with GlowBit.py and petme128.py inside it.

With the library installed, it's time to run our first demo. Open the GlowBit stick guide and go to the section entitled Running a Test Demo and copy and paste the first code example from that section into Thonny. Press Control S to save the file. We're going to save it to the Raspberry Pi Pico and call it main.py.

With the file saved, we can then press Control R to execute the script and you'll see some colorful test demos appear on your GlowBit stick.

The next thing we're going to do is look at how to control the color of individual pixels on the GlowBit stick module. Go into the guide, you can find the section Lighting Up Individual Pixels and as before, copy and paste the first code example into Thonny.

We can then press Control R and that will automatically save that script and then run it. After running the script, you'll see that the first two LEDs have been illuminated, the first one white and the second one a bluish color.

The crucial things to see in the script are:Are the pixels set function. This takes a pixel number and illuminates it with a particular color. The number is an integer between 0 or 7, where 0 is the LED on the left and 7 is the LED on the right. And color is a special GlowBit color value.

In this first example, it's been created with the function stick.white, which just returns a white color. There are several other color functions you can find in the guide. The other option is to use what's called the RGB color function. And this takes a red, green and blue value, all scaled between 0 and 255.

When you run the pixel set function, it doesn't actually change the color of the physical LED yet. What it does is write to an internal frame buffer. In order to change the color of the LEDs sitting on your desk, you need to execute the pixels show function.

The next thing we're going to look at is filling every pixel on the GlowBit stick with the same color. Moving to the guide, you can find the section entitled filling all pixels with a solid color. Copy and paste the first example into Thonny. Hitting control R to run this example, you should see all of the colors on the GlowBit stick light up with yellow.

The way this example works is it gets the yellow color from the stick.yellow function and then passes that to the stick.pixels fill function. This, as the name suggests, fills every single pixel on your GlowBit stick with whatever color you've given it. A call to pixel show then moves that frame buffer information onto the physical LEDs.

Back to the guide, we can move on to the next example. Scrolling down to the section entitled the color wheel, we can copy and paste the example that's there into Thonny. Pressing control R, this will then light up all of the LEDs with a color spectrum.

The core of this example is a call to the function stick.wheel. This function takes a single integer between 0 and 255 as its parameter. It then converts this integer into an RGB color value and sets every pixel on your GlowBit stick to the corresponding color.to 5. So now instead of the pulse updating every 20th frame, it's going to update every fifth frame. Let's run it with control R and you can see the pulse moving much faster. This is a great starting point for working with the GlowBit stick, and combining these different code examples is a great way to create all kinds of different effects.To create custom animations with the GlowBit stick, we're going to use a for loop along with the sleep function from the time module. Here's an example from the guide where we're creating three different animations: a ping-pong animation, a wave animation, and a heart pulse animation. To create the ping-pong animation, we're setting the brightness of every 5th pixel to be a value between 0 and 255. We're then reversing that list to create the ping-pong effect. For the wave animation, we're using the sin function from the math module to create a smooth wave pattern across the stick. Finally, for the heart pulse animation, we're using a list of brightness values that simulates a pulse.

Next, let's take a look at how to draw a graph on the GlowBit stick. In this context, a graph is a line of a certain length that's set by an input value. Scrolling down to the graph section in the guide, we'll copy and paste the first example into Thonny. Creating these graphs is a bit of a two-step process. The first step is this call to stick.graph1d. It will return a graph object that you then need to put into your own variable. Then to draw that graph onto the display, you call stick.updategraph with the graph object as the first argument and a new value as the second argument.

You'll see in this code that we're displaying values between zero and 255. By default, that's what the graph does. It takes the left-hand edge as a value of zero and the right-hand edge as a value of 255. In order to display an animation of this graph growing and then shrinking, we have two loops in this code. The first loop counts from zero to 255, updating the graph as it goes, and the second loop counts down from 255 to zero. By default, the graph draws a value of zero on the left-hand edge and a value of 255 on the right-hand edge. If you want to change this, you can use the minValue and maxValue keyword arguments when the graph is created. For example, we can change the maxValue to 512. Then when we rerun this code, it's only going to illuminate half of the pixels because 512 is then roughly in the middle.

Hopefully, this guide has been some great inspiration for your projects. If you make something cool from this guide or you just have some questions, leave us a message and we'll get back to you as soon as we can.I'm sorry, I do not have enough information to fully understand your request. Could you please provide me with more context or details on what you are looking for?

Comments


Loading...
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.