Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Testing the 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
- 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 * ledsarry[] ={leds1, leds2, leds3};
- void setup() {
- delay(2000); // power-up safety delay
- FastLED.addLeds<NEOPIXEL, Data_Pin>(leds, NUM_LEDS);
- FastLED.setBrightness(40);
- }
- void loop() {
- fill_solid(ledsarry[0], 8, CHSV( 213, 255, 255)); //8 is number of elements in the array
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[0], 8, CRGB::Black);
- FastLED.show();
- fill_solid(ledsarry[1], 8, CRGB::Green);
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[1], 8, CRGB::Black);
- FastLED.show();
- fill_solid(ledsarry[2], 8, CRGB::Blue);
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[2], 8, CRGB::Black);
- FastLED.show();
- fill_rainbow( ledsarry[0], 8, 0, 10);
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[0], 8, CRGB::Black);
- FastLED.show();
- fill_rainbow( ledsarry[1], 8, 80, 10);
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[1], 8, CRGB::Black);
- FastLED.show();
- fill_rainbow( ledsarry[2], 8, 180, 20);
- FastLED.show();
- delay(700);
- fill_solid( ledsarry[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(ledsarry[x], 8, color);
- FastLED.show();
- delay(wait);
- fill_solid( ledsarry[x], 8, CRGB::Black);
- FastLED.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment