Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemdoc77/e64cc690ba1de8cffae0ce04ca549915 to your computer and use it in GitHub Desktop.
Save chemdoc77/e64cc690ba1de8cffae0ce04ca549915 to your computer and use it in GitHub Desktop.
Step Project Examples with CRGBSet Arrays
// Step Project Array Code Example
// by Chemdoc77
#include "FastLED.h"
#define NUM_LEDS 390
#define Data_Pin 6
#define chipset NEOPIXEL
#define BRIGHTNESS 50
// CRGBSET Stuff
CRGB rawleds[NUM_LEDS];
CRGBSet leds(rawleds, NUM_LEDS);
CRGBSet step1(leds(0,29));
CRGBSet step2(leds(30,59));
CRGBSet step3(leds(60,89));
CRGBSet step4(leds(90,119));
CRGBSet step5(leds(120, 149));
CRGBSet step6(leds(150,179));
CRGBSet step7(leds(180,209));
CRGBSet step8(leds(210,239));
CRGBSet step9(leds(240,269));
CRGBSet step10(leds(270,299));
CRGBSet step11(leds(300,329));
CRGBSet step12(leds(330,359));
CRGBSet step13(leds(360,389));
struct CRGB * step_array[] ={step1,step2,step3,step4,step5,step6,step7,step8,step9,step10,step11,step12,step13};
uint8_t size_each_step_CRGBSet_array = 30; // size of each of the above step arrays
uint8_t size_step_array = 13; // size of step_array
//=============================
void setup() {
delay(2000); // power-up safety delay
FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.setMaxPowerInVoltsAndMilliamps(5,1500); // sets voltage and upper amperage level
set_max_power_indicator_LED(13);
}
//==============================
void loop() {
// fills the one step at a time
CD77_arrayfill(CRGB::Blue, 700);
CD77_arrayfill(CRGB::Red, 700);
// Fills one dot at a time per each step
CD77_colorwipe_dot(0, CRGB::Blue, 200);
CD77_colorwipe_dot(1, CRGB::Red, 200);
CD77_colorwipe_dot(2, CRGB::Green, 200);
}
//==============Functions=========
void CD77_colorwipe_dot(uint8_t step_number, CRGB color, uint32_t wait) {
for (uint8_t x = 0; x < size_each_step_CRGBSet_array; x++) {
step_array[step_number][x] = color;
FastLED.delay(wait);
step_array[step_number][x] =CRGB::Black;
}
}
void CD77_arrayfill(CRGB color, uint16_t wait){
for (uint8_t x=0; x<size_step_array; x++){
fill_solid(step_array[x], size_each_step_CRGBSet_array, color);
//FastLED.show();
//delay(wait);
FastLED.delay(wait);
fill_solid( step_array[x], size_each_step_CRGBSet_array, CRGB::Black);
FastLED.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment