SK6812 RGBW Jim Bumgardner hack

Hi all.
I'm trying to get Jim Bumgardner's hack via Dave Madison's 'parts not included' site. I've amended the sketch accordingly & saved the 'FastLED_RGBW.h' file accordingly.

On building I get the error;
DemoReel100mw:36:20: error: conflicting declaration 'CRGBW leds [20]'

On his site's screen-shot, the variables 'CRGB' & 'CRGBW' are different colours, indicating as not set correctly, how do I set these correctly?

This shows the difference bewteen his, & mine;
Capture

You have two variables named "leds", you only need one of them. Comment out the one you do not need, which depends on whether your LED's have a white component or not.

Hi. Thanks for quick reply. That's strange as it's as shown on his website, I omitted it out & it's still gives the error.

Here's the website link I'm going on;

Try to ask the author of that site.

Can't do mate, he only uses twitter or something.

Pictures of code are useless. Post YOUR complete code. Use Code Tags.

Great. Now try again with Code Tags as requested. If you don't know what that means, read this like you should have before posting your question:

Also, be sure to auto-format your code in the Arduino IDE (ctrl-t) before posting it.

#include <FastLED.h>
#include "FastLED_RGBW.h"

FASTLED_USING_NAMESPACE

// FastLED "100-lines-of-code" demo reel, showing just a few 
// of the kinds of animation patterns you can quickly and easily 
// compose using FastLED.  
//
// This example also shows one easy way to define multiple 
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif

#define DATA_PIN    3
//#define CLK_PIN   4
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS    16
//CRGB leds[NUM_LEDS];


//-------------------------------------------------------------------------
//ADDED FROM https://www.partsnotincluded.com/fastled-rgbw-neopixels-sk6812/
// FastLED
CRGB leds[NUM_LEDS];
 
// FastLED with RGBW
CRGBW leds[NUM_LEDS];
CRGB *ledsRGB = (CRGB *) &leds[0];
//-------------------------------------------------------------------------


#define BRIGHTNESS          96
#define FRAMES_PER_SECOND  120

void setup() {
  delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);




//-------------------------------------------------------------------------
//ADDED FROM https://www.partsnotincluded.com/fastled-rgbw-neopixels-sk6812/
  //FastLED with RGBW
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(ledsRGB, getRGBWsize(NUM_LEDS));
//-------------------------------------------------------------------------




  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  
void loop()
{
  // Call the current pattern function once, updating the 'leds' array
  gPatterns[gCurrentPatternNumber]();

  // send the 'leds' array out to the actual LED strip
  FastLED.show();  
  // insert a delay to keep the framerate modest
  FastLED.delay(1000/FRAMES_PER_SECOND); 

  // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
  EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti() 
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  byte dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}```

I'm not familiar with the "Jim Bumgardner hack". But, you're still trying to define two variables of different types with the same name:

CRGB leds[NUM_LEDS];
 
// FastLED with RGBW
CRGBW leds[NUM_LEDS];

I don't get why to use a hack, FASTLED supports SK6812 natively.

I'm running the RGBW ones, from what I read, Fastled does not support those with white led's included.

Hi @superspeedkings

try this code.

RV mineirin

#include <FastLED.h>
#include "FastLED_RGBW.h"

FASTLED_USING_NAMESPACE

// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
//
// This example also shows one easy way to define multiple
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif

#define DATA_PIN    3
//#define CLK_PIN   4
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS    16
//CRGB leds[NUM_LEDS];


//-------------------------------------------------------------------------
//ADDED FROM https://www.partsnotincluded.com/fastled-rgbw-neopixels-sk6812/
// FastLED
CRGB leds_RGB[NUM_LEDS];

// FastLED with RGBW
CRGBW ledsBWT[NUM_LEDS];
CRGB *ledsAll = (CRGB *) &ledsBWT[0];
//-------------------------------------------------------------------------


#define BRIGHTNESS          96
#define FRAMES_PER_SECOND  120

void setup() {
  delay(3000); // 3 second delay for recovery

  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds_RGB, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);




  //-------------------------------------------------------------------------
  //ADDED FROM https://www.partsnotincluded.com/fastled-rgbw-neopixels-sk6812/
  //FastLED with RGBW
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(ledsAll, getRGBWsize(NUM_LEDS));
  //-------------------------------------------------------------------------




  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns

void loop()
{
  // Call the current pattern function once, updating the 'leds' array
  gPatterns[gCurrentPatternNumber]();

  // send the 'leds' array out to the actual LED strip
  FastLED.show();
  // insert a delay to keep the framerate modest
  FastLED.delay(1000 / FRAMES_PER_SECOND);

  // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) {
    gHue++;  // slowly cycle the "base color" through the rainbow
  }
  EVERY_N_SECONDS( 10 ) {
    nextPattern();  // change patterns periodically
  }
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void rainbow()
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds_RGB, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter()
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter)
{
  if ( random8() < chanceOfGlitter) {
    leds_RGB[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti()
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds_RGB, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds_RGB[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds_RGB, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS - 1 );
  leds_RGB[pos] += CHSV( gHue, 255, 192);
}

void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for ( int i = 0; i < NUM_LEDS; i++) { //9948
   ledsBWT[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
  }
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds_RGB, NUM_LEDS, 20);
  byte dothue = 0;
  for ( int i = 0; i < 8; i++) {
    leds_RGB[beatsin16( i + 7, 0, NUM_LEDS - 1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

These lines are NOT in the Example Sketch on that page.

Hi ruilviana that's great, all up & running now. :wink:

I thought by now the Fastled library would facilitate the RGBW type, but nevertheless I'm back on track. I should take time to learn C language, I program in assembly, predominantly on PIC chips.

Regards, Mark

Although I did test it on my led's to see if it worked I'm not using the example sketch in my application, but the arduino DemoReel100 sketch - modified as per the page's suggestions. :wink:

Mark.

I think this 'suggestion':

// FastLED
CRGB leds[NUM_LEDS];
 
// FastLED with RGBW
CRGBW leds[NUM_LEDS];
CRGB *ledsRGB = (CRGB *) &leds[0];

was to be read as:

// Original FastLED, remove this line:
// CRGB leds[NUM_LEDS];
 
// FastLED with RGBW, add these lines in its place
CRGBW leds[NUM_LEDS];
CRGB *ledsRGB = (CRGB *) &leds[0];
2 Likes

Thanks John. Some of the patterns are better, but for now think on this project I'll revert back to RGB type without the white led included & try to use these later on. :wink:

Mark.

Syntax highlighting in the IDE does not mean anything; it's based on keywords in a text file in the libraries. If the CRGBW word is not in that file, it will not appear in a different colour.

The main problem is the standard WS2811 library is not compatible with RGB+W, just RGB, so he's made a 'work-around', but it only work on some routines, I'm going to change back to the older RGB type, without the white led.

I was wondering what you meant by that, but you mean the effects examples i guess. Look, one should look at it like that. These are just examples. Pretty sure you can modify the individual functions to deal with RGBW easy enough, just not using the white is what the hack attempts to do, but for some of the routines the size of the variable may matter. You would anyway be using RGBW as RGB Leds, so you may as well just use RGB leds.