How it works...
The first line of code imports the cpx object that will be used to control the NeoPixels. This object has an attribute called pixels, which can be accessed like a list. The index that is used indicates which of the 10 NeoPixels is to be manipulated.
In the first code snippet, we set the value to a tuple that represents the desired color—it is comprised of red, green, and blue values. Each value should be represented as an integer from 0 to 255. By setting the value to (255, 0, 0), the red LED will be at its highest value and the green and blue LEDs will be switched off. This will create the color red.
Following the same approach, the NeoPixel is then set to green and blue by providing the correct values for each of those colors. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access