Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ArrayOfLedArrays with strips of different length test
- // Marc Miller, Apr 2016
- //---------------------------------------------------------------
- #include "FastLED.h"
- #define LED_TYPE NEOPIXEL
- #define NUM_STRIPS 12 // Total number of strips
- #define NUM_LEDS1 84 // Specify length of each strip
- #define NUM_LEDS2 78
- #define NUM_LEDS3 72
- #define NUM_LEDS4 66
- #define NUM_LEDS5 60
- #define NUM_LEDS6 54
- #define NUM_LEDS7 48
- #define NUM_LEDS8 42
- #define NUM_LEDS9 36
- #define NUM_LEDS10 30
- #define NUM_LEDS11 24
- #define NUM_LEDS12 47
- //etc.
- CRGB leds[NUM_STRIPS][NUM_LEDS1 + NUM_LEDS2 + NUM_LEDS3 + NUM_LEDS4 + NUM_LEDS5 + NUM_LEDS6 + NUM_LEDS7 + NUM_LEDS8 + NUM_LEDS9 + NUM_LEDS10 + NUM_LEDS11 + NUM_LEDS12]; // Add all together here
- uint8_t stripLength; // Used to store a strip length.
- //---------------------------------------------------------------
- void setup() {
- delay(3000);
- FastLED.addLeds<LED_TYPE, 2>(leds[0], NUM_LEDS1); // Assign data pins
- FastLED.addLeds<LED_TYPE, 3>(leds[1], NUM_LEDS2);
- FastLED.addLeds<LED_TYPE, 4>(leds[2], NUM_LEDS3);
- FastLED.addLeds<LED_TYPE, 5>(leds[0], NUM_LEDS4);
- FastLED.addLeds<LED_TYPE, 6>(leds[1], NUM_LEDS5);
- FastLED.addLeds<LED_TYPE, 7>(leds[2], NUM_LEDS6);
- FastLED.addLeds<LED_TYPE, 8>(leds[0], NUM_LEDS7);
- FastLED.addLeds<LED_TYPE, 9>(leds[1], NUM_LEDS8);
- FastLED.addLeds<LED_TYPE, 10>(leds[2], NUM_LEDS9);
- FastLED.addLeds<LED_TYPE, 11>(leds[0], NUM_LEDS10);
- FastLED.addLeds<LED_TYPE, 12>(leds[1], NUM_LEDS11);
- FastLED.addLeds<LED_TYPE, 13>(leds[2], NUM_LEDS12);
- //etc.
- }
- //---------------------------------------------------------------
- void loop() {
- for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- stripLength = getStripLength(x);
- fill_rainbow( leds[x], stripLength, millis()/3, 256/stripLength );
- }
- FastLED.show();
- delay(3000);
- for(uint8_t x = 0; x < NUM_STRIPS; x++) {
- stripLength = getStripLength(x);
- uint8_t randomColor = random8();
- fill_solid(leds[x], stripLength, CHSV(randomColor,255,255));
- }
- FastLED.show();
- delay(2000);
- FastLED.clear(); // Clear all data
- FastLED.show();
- delay(1000);
- }//end main loop
- //-----function to return strip length-----
- uint8_t getStripLength(uint8_t stripNumber){
- uint8_t L;
- if (stripNumber == 0) { L = NUM_LEDS1; }
- if (stripNumber == 1) { L = NUM_LEDS2; }
- if (stripNumber == 2) { L = NUM_LEDS3; }
- if (stripNumber == 3) { L = NUM_LEDS4; }
- if (stripNumber == 4) { L = NUM_LEDS5; }
- if (stripNumber == 5) { L = NUM_LEDS6; }
- if (stripNumber == 6) { L = NUM_LEDS7; }
- if (stripNumber == 7) { L = NUM_LEDS8; }
- if (stripNumber == 8) { L = NUM_LEDS9; }
- if (stripNumber == 9) { L = NUM_LEDS10; }
- if (stripNumber == 10) { L = NUM_LEDS11; }
- if (stripNumber == 11) { L = NUM_LEDS12; }
- return L;
- }
Advertisement
Add Comment
Please, Sign In to add comment