An Arduino, a bit of ws2812 LED strip, and some sanded acrylic tube make the perfect light for a jack-o-lantern. If you’ve ever wanted to play with the intelligent LEDs like the ws2812, I highly recommend using FastLED to drive them. The library has a good set of examples bundled with it, one of which is the Fire2012 example. You can see that in action in the embedded video below. For these two pumpkins, I used some very simple code that cycles them through the HSV color wheel at 100% saturation and 100% value. See the code at the end of the post.

And now for the code:
#include "FastLED.h"
#define NUM_LEDS 20
#define LED_PIN 5
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds(leds, NUM_LEDS);
}
#define HUE_DELTA 1
#define TIMEOUT 200
void loop() {
static uint8_t hue = 0;
// Turn the LED on, then pause
for( int idx = 0; idx < NUM_LEDS; idx++)
{
leds[idx].setHSV( hue, 0xff, 0xff);
}
FastLED.show();
delay(TIMEOUT);
hue += HUE_DELTA;
}

November 1st, 2016
bitreaper
Posted in