Neopixel addressable LEDs
LEDs! Bright, colourful fun things that are often seen as tacky, or simple – but that just means you haven’t experimented with the nature of light itself!
In this recipe we are dealing with addressable LED strips. These are very different to 12V RGB LED strips.
NeoPixels are also known as WS2812B pixels. NeoPixel is the ‘brand’ given by Adafruit, a popular electronic prototyping store based in New York City, US. WS2812B is the actual part number of the addressable LED chips. They operate at 5VDC and will not do well if over/underpowered.
A crucial differentiator between these RGB strips and ‘addressable’ versions (the NeoPixels, WS2812B etc) is that you can change the colour output of a 12V RGB strip ALL AT ONCE, but not individually. That’s where the ‘addressable’ part of NeoPixels come in.
For more information on NeoPixels, check the Neopixel Überguide here.
You might also have come across DotStar addressable LEDs, which use the APA102C chipset. A cheaper knockoff version of the APA102C is the SK9822. All of these different addressable LED technologies will require a a library that supports driving them. Once you get past the basics, you might be interested in the more versatile and full-featured FastLED library as an all-in-one solution for driving any of these addressable LED pixels.
A typical Neopixel will draw up to 60mA (0.06A). An 8-Neopixel stick will draw up to 480mA (0.48A) at full white brightness. Just like the 12V RGB LED strips, power consumption adds up, so make sure you choose the right 5V power supply. We’ll just get by with the USB port’s 500mA in this recipe, but you definitely want to use either a wall-wart transformer, or one of those USB portable power banks for your phones if you want a more robust setup.
You can swap out the light sensor with any other analog sensor in your kit, so long as you modify the code to suitably adjust the scaling of the sensor readings in relation to the desired output.
The code is getting the ambient light sensor to alter the speed at which the trippy rainbow animation is cycling. The scope of programming complex colour shifts might be too big to handle here, but follow this useful library guide as a good start. We can talk more about writing more specific code in class, as needed.
(learn how to import them in the Build IDE):