Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chemdoc77/31632b540908b6788c9340989eeb8bfc to your computer and use it in GitHub Desktop.
Save chemdoc77/31632b540908b6788c9340989eeb8bfc to your computer and use it in GitHub Desktop.
// Testing FastLED's CRGBSet array with a fill the whole array function and with a colorwipe function
// 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}; // An array of the CRGBSet arrays
uint8_t sizearray[]= {8,8,8}; // size of the above arrays
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() {
// fills the whole array
CD77_arrayfill(CRGB::Blue, 700);
CD77_arrayfill(CRGB::Red, 700);
// Fills one dot at a time
CD77_colorwipe_dot(0, CRGB::Blue, 200);
CD77_colorwipe_dot(1, CRGB::Red, 200);
CD77_colorwipe_dot(2, CRGB::Green, 200);
}
//================ New Functions =====================
void CD77_colorwipe_dot(uint8_t y, CRGB color, uint32_t wait) { //Note: y is ledarray number
for (uint8_t x = 0; x < sizearray[y]; x++) {
ledarray[y][x] = color;
FastLED.delay(wait);
ledarray[y][x] =CRGB::Black;
}
}
void CD77_arrayfill(CRGB color, uint16_t wait){
for (uint8_t x=0; x<3; x++){
fill_solid(ledarray[x], sizearray[x], color);
FastLED.show();
delay(wait);
fill_solid( ledarray[x], sizearray[x], CRGB::Black);
FastLED.show();
}
}
@goinheix
Copy link

Hi, I've been reading your replies on every forum about FastLED and they've helped me a lot, so thank you. I have a question:

On lines 11-15 you declare some CRGBSet arrays. I need to do the same but they are 100 (it's contiguous groups of 2 LEDs on a 200 LED strip). Should I do this manually or is there a way of making it through a loop?

Thank you!

@chemdoc77
Copy link
Author

chemdoc77 commented Nov 20, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment