(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++)    { [...]">

ElectroPumpkins for Halloween

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.

20161030_224005   20161030_235938   20161031_204650

 

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;
}

 

Both comments and pings are currently closed.

Comments are closed.

CRM