This week I worked with addressable LEDs. I started with a simple 8 pixel NeoPixel strip to get the wiring and code basics down, then moved on to a 2x2 grid of NeoPixels for my logo's four dots, first lighting it as a static logo, then adding a fade in/out.
NeoPixels and similar addressable LEDs each have a driver chip built directly into the LED package, so every pixel can be set to its own colour over a single data line. They're wired in a chain, with data in on one end and data out to the next pixel. You only need to use one data pin to write to all of them.
Both the Adafruit_NeoPixel and FastLED are great libraries that handle effects and colour addressing for you. NeoPixel is the simpler of the two: set a pixel with strip.setPixelColor() and push it out with strip.show(). FastLED works with an internal CRGB/CHSV array that you write to directly, and adds extra helpers for colour blending, palettes, and global brightness control via FastLED.show().
HSV describes a colour as hue (which colour, 0-255), saturation, and value (brightness), instead of mixing red/green/blue. This makese animation and shifting colours very easy, which can be done by simply ramping a number rather than changing RGB values.
I started with a simple 8 pixel NeoPixel strip to confirm the wiring and a basic addressable LED sketch.
Wired up to the Barduino on a breadboard, I ran a colour wipe test, stepping through a few shades of red/orange one pixel at a time.
Download strandtest-colourwipe-test-8LEDs.ino
For the pomodoro timer watch I designed for week 08 (electronics poduction) I had wanted to embed 4 NeoPixels into the watch face. For this test, I wired them into a 2x2 grid using two strip of two.
I ran a quick test with all four pixels set to the same colour, just to confirm the wiring and data chain were good.
With the wiring confirmed, I mapped each of the 4 pixels to one of the dots in my logo using CHSV values, then set a static brightness.
I had to adjust the CHSV values by eye until they matched the colours of my logo more closesly.
I wanted to see how these might shine through transparent PETG, for the watch face.
Download static-logo-neopixels.ino
Last, I took the static logo sketch and added a brightness ramp, the whole logo fades in, holds, fades back out, pauses, then repeats.