gabriel stacey-chartrand

Week 10: output devices

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.

Addressable LEDs

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.

NeoPixel / FastLED libraries

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 colour space

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.

Addressable LED strip test

I started with a simple 8 pixel NeoPixel strip to confirm the wiring and a basic addressable LED sketch.

8 pixel NeoPixel strip with tinned pads
wires soldered onto the strip

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.

strip wired to the Barduino on the breadboard, mid colour-wipe

Download strandtest-colourwipe-test-8LEDs.ino

2x2 grid

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.

2x2 grid

I ran a quick test with all four pixels set to the same colour, just to confirm the wiring and data chain were good.

2x2 grid wired to the Barduino, all four pixels set to the same colour

Static logo

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.

each pixel set to its CHSV equivalent of the logo's colours

I had to adjust the CHSV values by eye until they matched the colours of my logo more closesly.

static logo with adjusted CHSV colours

I wanted to see how these might shine through transparent PETG, for the watch face.

diffusing through transparent PETG

Download static-logo-neopixels.ino

Fading logo

Last, I took the static logo sketch and added a brightness ramp, the whole logo fades in, holds, fades back out, pauses, then repeats.

Download fade-logo-neopixels.ino

Group page for week 10
Country roads...