jasoncoon

NeoPixels 12 Rings - Modified

Jul 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | None | 0 0
  1. // ArrayOfLedArrays with strips of different length test
  2. // Marc Miller, Apr 2016
  3. //---------------------------------------------------------------
  4.  
  5. #include "FastLED.h"
  6. #define LED_TYPE NEOPIXEL
  7. #define NUM_STRIPS 12  // Total number of strips
  8.  
  9. #define NUM_LEDS1 84   // Specify length of each strip
  10. #define NUM_LEDS2 78
  11. #define NUM_LEDS3 72
  12. #define NUM_LEDS4 66
  13. #define NUM_LEDS5 60
  14. #define NUM_LEDS6 54
  15.  
  16. #define NUM_LEDS7 48  
  17. #define NUM_LEDS8 42
  18. #define NUM_LEDS9 36
  19. #define NUM_LEDS10 30
  20. #define NUM_LEDS11 24
  21.  
  22. #define NUM_LEDS12 47
  23. //etc.
  24.  
  25. CRGB leds[NUM_STRIPS][NUM_LEDS1];
  26.  
  27. uint8_t stripLength;  // Used to store a strip length.
  28.  
  29.  
  30. //---------------------------------------------------------------
  31. void setup() {
  32.  
  33.   delay(3000);
  34.   FastLED.addLeds<LED_TYPE, 2>(leds[0], NUM_LEDS1);  // Assign data pins
  35.   FastLED.addLeds<LED_TYPE, 3>(leds[1], NUM_LEDS2);
  36.   FastLED.addLeds<LED_TYPE, 4>(leds[2], NUM_LEDS3);
  37.  
  38.   FastLED.addLeds<LED_TYPE, 5>(leds[3], NUM_LEDS4);
  39.   FastLED.addLeds<LED_TYPE, 6>(leds[4], NUM_LEDS5);
  40.   FastLED.addLeds<LED_TYPE, 7>(leds[5], NUM_LEDS6);
  41.  
  42.   FastLED.addLeds<LED_TYPE, 8>(leds[6], NUM_LEDS7);  
  43.   FastLED.addLeds<LED_TYPE, 9>(leds[7], NUM_LEDS8);
  44.   FastLED.addLeds<LED_TYPE, 10>(leds[8], NUM_LEDS9);
  45.   FastLED.addLeds<LED_TYPE, 11>(leds[9], NUM_LEDS10);  
  46.   FastLED.addLeds<LED_TYPE, 12>(leds[10], NUM_LEDS11);
  47.  
  48.   FastLED.addLeds<LED_TYPE, 13>(leds[11], NUM_LEDS12);
  49.   //etc.
  50. }
  51.  
  52.  
  53. //---------------------------------------------------------------
  54. void loop() {
  55.   for(uint8_t x = 0; x < NUM_STRIPS; x++) {
  56.     stripLength = getStripLength(x);
  57.     fill_rainbow( leds[x], stripLength, millis()/3, 256/stripLength );
  58.   }
  59.   FastLED.show();
  60.   delay(3000);
  61.  
  62.   for(uint8_t x = 0; x < NUM_STRIPS; x++) {
  63.     stripLength = getStripLength(x);
  64.     uint8_t randomColor = random8();
  65.     fill_solid(leds[x], stripLength, CHSV(randomColor,255,255));
  66.   }
  67.   FastLED.show();
  68.   delay(2000);
  69.  
  70.   FastLED.clear();  // Clear all data
  71.   FastLED.show();
  72.   delay(1000);
  73.  
  74. }//end main loop
  75.  
  76.  
  77. //-----function to return strip length-----
  78. uint8_t getStripLength(uint8_t stripNumber){
  79.   uint8_t L;
  80.   if (stripNumber == 0) { L = NUM_LEDS1; }
  81.   if (stripNumber == 1) { L = NUM_LEDS2; }
  82.   if (stripNumber == 2) { L = NUM_LEDS3; }
  83.   if (stripNumber == 3) { L = NUM_LEDS4; }
  84.   if (stripNumber == 4) { L = NUM_LEDS5; }
  85.   if (stripNumber == 5) { L = NUM_LEDS6; }
  86.  
  87.   if (stripNumber == 6) { L = NUM_LEDS7; }
  88.   if (stripNumber == 7) { L = NUM_LEDS8; }
  89.   if (stripNumber == 8) { L = NUM_LEDS9; }
  90.   if (stripNumber == 9) { L = NUM_LEDS10; }
  91.   if (stripNumber == 10) { L = NUM_LEDS11; }
  92.  
  93.   if (stripNumber == 11) { L = NUM_LEDS12; }
  94.  
  95.   return L;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment