Helmet Larson Scanner

Now that I’m biking more, I’ve begun outfitting my helmet with lots of useless practical tech in the name of safety.  Not long ago, I found the helmet-mounted flashlight that I used during my deployments.  With a little finagling, it fit nicely on my bike helmet as well.  To complement that front-facing flashlight, I finished this project featured here: rear safety lights.  These lights are just like cylon scanners, or KITT’s strobe in Knight Rider.  It’s basically a strip of LEDs that bounces back and forth from edge to edge.

The brains behind the light show is a Trinket, Adafruit’s mini Arduino-compatible micro controller based on the Atmel ATtiny85 chip.  It’s extremely lightweight and fairly easy to configure.  Here’s a photo of the Trinket connected to the NeoPixel strip via a protoboard.

helmet_1

I mounted all of the components, to include the LEDs, Trinket micro controller and power on the back of the helmet using some 3M DualLock.

helmet_2

 

Here’s the code, note that it requires the Adafruit Neopixel Library:

#include <Adafruit_NeoPixel.h>

#define N_LEDS 8
#define PIN 0

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
 strip.begin();
}

int pos = 0, dir = 1; // Position, direction of "eye"

void loop() {
 int j;

// Draw 5 pixels centered on pos. setPixelColor() will clip any
 // pixels off the ends of the strip, we don't need to watch for that.
 strip.setPixelColor(pos - 2, 0x100000); // Dark red
 strip.setPixelColor(pos - 1, 0x800000); // Medium red
 strip.setPixelColor(pos , 0xFF3000); // Center pixel is brightest
 strip.setPixelColor(pos + 1, 0x800000); // Medium red
 strip.setPixelColor(pos + 2, 0x100000); // Dark red

strip.show();
 delay(60);

// Rather than being sneaky and erasing just the tail pixel,
 // it's easier to erase it all and draw a new one next time.
 for (j = -2; j <= 2; j++) strip.setPixelColor(pos + j, 0);

// Bounce off ends of strip
 pos += dir;
 if (pos < 0) {
 pos = 1;
 dir = -dir;
 } else if (pos >= strip.numPixels()) {
 pos = strip.numPixels() - 2;
 dir = -dir;
 }
}

Here’s what it looks like in action.  Hopefully drivers don’t get target fixation on the strobes.

helmet_3