Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing FastLED's CRGBSet array function and using it with the fill_solid and fill_rainbow functions.
// Testing FastLED's CRGBSet array function and using it with the fill_solid and fill_rainbow functions.
// by Chemdoc77
#include "FastLED.h"
#define NUM_LEDS 24
#define Data_Pin 6
#define chipset NEOPIXEL
#define BRIGHTNESS 50
CRGB rawleds[NUM_LEDS];
CRGBSet leds(rawleds, NUM_LEDS);
CRGBSet leds1(leds(0,7));
CRGBSet leds2(leds(8,15));
CRGBSet leds3(leds(16,23));
struct CRGB * ledarray[] ={leds1, leds2, leds3};
void setup() {
delay(2000); // power-up safety delay
FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.setMaxPowerInVoltsAndMilliamps(5,1500);
set_max_power_indicator_LED(13);
}
void loop() {
fill_solid(ledarray[0], 8, CHSV( 213, 255, 255)); //8 is number of elements in the array
FastLED.show();
delay(700);
fill_solid( ledarray[0], 8, CRGB::Black);
FastLED.show();
fill_solid(ledarray[1], 8, CRGB::Green);
FastLED.show();
delay(700);
fill_solid( ledarray[1], 8, CRGB::Black);
FastLED.show();
fill_solid(ledarray[2], 8, CRGB::Blue);
FastLED.show();
delay(700);
fill_solid( ledarray[2], 8, CRGB::Black);
FastLED.show();
fill_rainbow( ledarray[0], 8, 0, 10);
FastLED.show();
delay(700);
fill_solid( ledarray[0], 8, CRGB::Black);
FastLED.show();
fill_rainbow( ledarray[1], 8, 80, 10);
FastLED.show();
delay(700);
fill_solid( ledarray[1], 8, CRGB::Black);
FastLED.show();
fill_rainbow( ledarray[2], 8, 180, 20);
FastLED.show();
delay(700);
fill_solid( ledarray[2], 8, CRGB::Black);
FastLED.show();
cd77_arrayfill(CRGB::Blue, 700);
cd77_arrayfill(CRGB::Red, 700);
}
//================ New Function =====================
void cd77_arrayfill(CRGB color, uint16_t wait){
for (uint8_t x=0; x<3; x++){
fill_solid(ledarray[x], 8, color);
FastLED.show();
delay(wait);
fill_solid( ledarray[x], 8, CRGB::Black);
FastLED.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.