James_sfx

NeoPixels 12 Rings

Jul 25th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 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 + 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
  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. FastLED.addLeds<LED_TYPE, 5>(leds[0], NUM_LEDS4);
  38. FastLED.addLeds<LED_TYPE, 6>(leds[1], NUM_LEDS5);
  39. FastLED.addLeds<LED_TYPE, 7>(leds[2], NUM_LEDS6);
  40.  
  41. FastLED.addLeds<LED_TYPE, 8>(leds[0], NUM_LEDS7);
  42. FastLED.addLeds<LED_TYPE, 9>(leds[1], NUM_LEDS8);
  43. FastLED.addLeds<LED_TYPE, 10>(leds[2], NUM_LEDS9);
  44. FastLED.addLeds<LED_TYPE, 11>(leds[0], NUM_LEDS10);
  45. FastLED.addLeds<LED_TYPE, 12>(leds[1], NUM_LEDS11);
  46.  
  47. FastLED.addLeds<LED_TYPE, 13>(leds[2], NUM_LEDS12);
  48. //etc.
  49. }
  50.  
  51.  
  52. //---------------------------------------------------------------
  53. void loop() {
  54. for(uint8_t x = 0; x < NUM_STRIPS; x++) {
  55. stripLength = getStripLength(x);
  56. fill_rainbow( leds[x], stripLength, millis()/3, 256/stripLength );
  57. }
  58. FastLED.show();
  59. delay(3000);
  60.  
  61. for(uint8_t x = 0; x < NUM_STRIPS; x++) {
  62. stripLength = getStripLength(x);
  63. uint8_t randomColor = random8();
  64. fill_solid(leds[x], stripLength, CHSV(randomColor,255,255));
  65. }
  66. FastLED.show();
  67. delay(2000);
  68.  
  69. FastLED.clear(); // Clear all data
  70. FastLED.show();
  71. delay(1000);
  72.  
  73. }//end main loop
  74.  
  75.  
  76. //-----function to return strip length-----
  77. uint8_t getStripLength(uint8_t stripNumber){
  78. uint8_t L;
  79. if (stripNumber == 0) { L = NUM_LEDS1; }
  80. if (stripNumber == 1) { L = NUM_LEDS2; }
  81. if (stripNumber == 2) { L = NUM_LEDS3; }
  82. if (stripNumber == 3) { L = NUM_LEDS4; }
  83. if (stripNumber == 4) { L = NUM_LEDS5; }
  84. if (stripNumber == 5) { L = NUM_LEDS6; }
  85.  
  86. if (stripNumber == 6) { L = NUM_LEDS7; }
  87. if (stripNumber == 7) { L = NUM_LEDS8; }
  88. if (stripNumber == 8) { L = NUM_LEDS9; }
  89. if (stripNumber == 9) { L = NUM_LEDS10; }
  90. if (stripNumber == 10) { L = NUM_LEDS11; }
  91.  
  92. if (stripNumber == 11) { L = NUM_LEDS12; }
  93.  
  94. return L;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment