Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define LED_TYPE NEOPIXEL
- #define NUM_STRIPS 6 // Total number of strips
- #define NUM_LEDS0 16 // Specify length of each strip
- #define NUM_LEDS1 21
- #define NUM_LEDS2 32
- #define BRIGHTNESS 20
- #define FRAMES_PER_SECOND 120
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
- //etc.
- CRGB leds[NUM_STRIPS][NUM_LEDS0 + NUM_LEDS1 + NUM_LEDS2]; // Add all together here
- uint8_t stripLength; // Used to store a strip length.
- uint8_t chanceOfGlitter = 80;
- bool gReverseDirection = false;
- //---------------------------------------------------------------
- void setup() {
- Serial.begin(115200); // Allows serial monitor output (check baud rate)
- delay(3000);
- FastLED.addLeds<LED_TYPE, 3>(leds[0], NUM_LEDS0); // Assign data pins
- FastLED.addLeds<LED_TYPE, 9>(leds[1], NUM_LEDS1);
- FastLED.addLeds<LED_TYPE, 6>(leds[2], NUM_LEDS2);
- FastLED.setBrightness( BRIGHTNESS );
- }
- typedef void (*SimplePatternList[])();
- SimplePatternList gPatterns = { sinelon };
- uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
- uint8_t gHue = 0; // rotating "base color" used by many of the patterns
- //---------------------------------------------------------------
- void loop() {
- // Call the current pattern function once, updating the 'leds' array
- gPatterns[gCurrentPatternNumber]();
- // send the 'leds' array out to the actual LED strip
- FastLED.show();
- // insert a delay to keep the framerate modest
- FastLED.delay(1000/FRAMES_PER_SECOND);
- // do some periodic updates
- EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
- EVERY_N_SECONDS( 20 ) { nextPattern(); } // change patterns periodically
- }//end main loop
- //-----function to return strip length-----
- uint8_t getStripLength(uint8_t stripNumber){
- uint8_t L;
- if (stripNumber == 0) { L = NUM_LEDS0; }
- if (stripNumber == 1) { L = NUM_LEDS1; }
- if (stripNumber == 2) { L = NUM_LEDS2; }
- return L;
- }
- void nextPattern()
- {
- // add one to the current pattern number, and wrap around at the end
- gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
- }
- //void confetti(void)
- // {
- //
- // // Gradiant filled with confetti
- //for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- // static uint16_t stripLength = getStripLength(x);
- // fill_gradient(leds[x], 0, CHSV(10,200,255), stripLength, CHSV(160,200,255), BACKWARD_HUES);
- // fadeToBlackBy(leds[x], stripLength,10);
- // int pos = random16(stripLength);
- // leds[x][pos]+= CHSV(gHue + random8(64),200,255);
- // delay(10);
- // }
- // }
- //
- // void glitter(void)
- //{
- //// Solid filled with Glitter
- //for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- // static uint16_t stripLength = getStripLength(x);
- // fill_solid( leds[x], stripLength, CRGB(0,50,255));
- // if (random8()<chanceOfGlitter)
- // {
- // leds[x][random16(stripLength)] += CRGB::White;
- //
- // }
- //}
- //}
- //
- //
- //void rainbow(void)
- //{
- //for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- // static uint16_t stripLength = getStripLength(x);
- // fill_rainbow( leds[x], stripLength, -1*millis()/2, 256/stripLength );
- //}
- //}
- void sinelon(void)
- {
- // Sinelon
- for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- static uint16_t stripLength = getStripLength(x);
- fill_solid(leds[0], stripLength, CHSV( gHue, 255, 192));
- fadeToBlackBy( leds[x], stripLength, 20);
- int pos = beatsin16(10,0,stripLength);
- leds[x][pos] += CHSV( gHue, 255, 192);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment