Question on controlling a single WS2812B LED

Hi and Merry Christmas!

My question may seem rather simple to some but I'm having a difficult time trying to wrap my head around how I can control the colour and the the brightness of a single LED in a WS2812 addressable light strip.

I've downloaded the Adafruit_NeoPixel library and have a strip of lights doing all sorts of interesting patterns but the code itself doesn't explain the basics of controlling a single LED. I would think having that basic info would be rather helpful.

I've searched for days on the net for an example but alas have yet to find one.

I'm not new to programming but sometimes I need to know the absolute basics before i can get running with it.

Any help you can provide would be greatly apreciated.


Is this a trick question?

Perhaps counterintuitiveā€¦ you just need to think of it as a strip of one.

Take any example you have running a strip. If you put your hand over all but the first LED you are looking at a "strip" of one pixel, controlled by the data you put in slot 0. Or maybe it's the last one, not sure. In any case

set the number of pixels to 1 when you create the strip object, then address only the pixel at index 0. You should be seeing what you want. The actions will be exactly the same as would appear in for loops over an index, for example, but you won't need loops 'cause there's only 1 pixel. Otherwise all the expressions look the same, just an index of 0, not i.

Google 'control one neopixel'.


-- a7

At the lowest level, all the library does is send 3 bytes to each WS2812B. One byte to set the 8-bit PWM level for red, one for green, one for blue. The WS2812B then turns the 3 outputs on & off very fast so the colors don't appear to flicker, same as the Arduino does when you use analogWrite (pin, Level) with level from 0 (off) to 255 (full on). Lower values of PWM are dimmer as the LED is on for less time periods out of 255 possible time periods. Color is determined by the mix of colors. Google "color wheel" to see the amounts of each primary light color to make other colors. If you wanted dim purple, you might use values of 10 each for red & blue for example. Bright purple might use 200 and 200. Maybe throw in some green for Deep Purple 8)

Thanks for the explaination CrossRoads.