Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement