CRGBArray Question
Is there a way to create a set of leds that is every other led or every third led?
like this = 1 2 1 2 1 2 or this 1 2 3 1 2 3 1 2 3 1 2 3
I can do it with a for loop but that’s no fun
marmil
(Marc Miller)
April 23, 2017, 8:26pm
2
No, currently only a continuous string of pixels can be used with CRGBArray. I usually use some sort of formula if I want to do a certain pixel spacing.
Here’s a repeating pattern example:
//***************************************************************
// If we want a pattern to repeat every 5 pixels then the
// first pixel set to light up would be: 0,5,10,15,20...
// This can be represented by: leds[5 * (x - 1) + 5]
//
// Let's put this into a loop with some variables!
//
//
// Marc Miller, Nov 2015
// May 2020 - replaced all delays with EVERY_N
//***************************************************************
#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
#define MASTER_BRIGHTNESS 100
CRGB leds[NUM_LEDS];
This file has been truncated. show original
And here’s a marquee example where the spacing can be adjusted (even while running).
//***************************************************************
// Marquee fun (v3)
// Pixel position down the strip comes from this formula:
// pos = spacing * (i-1) + spacing
// i starts at 0 and is incremented by +1 up to NUM_LEDS/spacing.
//
// Marc Miller, May 2016
// Updated June 2018 - reordered some stuff and small bug fix.
//***************************************************************
#include "FastLED.h"
#define LED_TYPE LPD8806
#define NUM_LEDS 32
#define COLOR_ORDER GRB
//#define LED_TYPE APA102
//#define NUM_LEDS 39
//#define COLOR_ORDER BGR
#define DATA_PIN 11
This file has been truncated. show original
Fantastic, thanks for the quick reply!
There is a plan to eventually support skip definitions like this, but not yet.