Guest User

Rainbow Flows

a guest
Apr 20th, 2016
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 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 6  // Total number of strips
  8.  
  9. #define NUM_LEDS0 11   // Specify length of each strip
  10. #define NUM_LEDS1 13
  11. #define NUM_LEDS2 17
  12. #define NUM_LEDS3 20
  13. #define NUM_LEDS4 21
  14. #define NUM_LEDS5 23
  15.  
  16. #define BRIGHTNESS  20
  17. #define FRAMES_PER_SECOND  240
  18. //etc.
  19.  
  20. CRGB leds[NUM_STRIPS][NUM_LEDS0 + NUM_LEDS1 + NUM_LEDS2 + NUM_LEDS3 + NUM_LEDS4 + NUM_LEDS5];  // Add all together here
  21.  
  22. uint8_t stripLength;  // Used to store a strip length.
  23. uint8_t gHue = 0;
  24.  
  25. //---------------------------------------------------------------
  26. void setup() {
  27.   Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  28.   delay(3000);
  29.   FastLED.addLeds<LED_TYPE, 6>(leds[0], NUM_LEDS0);  // Assign data pins
  30.   FastLED.addLeds<LED_TYPE, 9>(leds[1], NUM_LEDS1);
  31.   FastLED.addLeds<LED_TYPE, 10>(leds[2], NUM_LEDS2);
  32.   FastLED.addLeds<LED_TYPE, 11>(leds[3], NUM_LEDS3);
  33.   FastLED.addLeds<LED_TYPE, 12>(leds[4], NUM_LEDS4);
  34.   FastLED.addLeds<LED_TYPE, 13>(leds[5], NUM_LEDS5);
  35.   //etc.
  36.    FastLED.setBrightness(  BRIGHTNESS );
  37. }
  38.  
  39.  
  40. //---------------------------------------------------------------
  41. void loop() {
  42.  
  43.  
  44. for(uint8_t x = 0; x < NUM_STRIPS; x++) {
  45.     stripLength = getStripLength(x);
  46.     fill_rainbow( leds[x], stripLength, millis()/2, 256/stripLength );
  47.   }
  48.  
  49. FastLED.show();
  50.  
  51. }//end main loop
  52.  
  53. //-----function to return strip length-----
  54. uint8_t getStripLength(uint8_t stripNumber){
  55.   uint8_t L;
  56.   if (stripNumber == 0) { L = NUM_LEDS0; }
  57.   if (stripNumber == 1) { L = NUM_LEDS1; }
  58.   if (stripNumber == 2) { L = NUM_LEDS2; }
  59.   if (stripNumber == 3) { L = NUM_LEDS3; }
  60.   if (stripNumber == 4) { L = NUM_LEDS4; }
  61.   if (stripNumber == 5) { L = NUM_LEDS5; }
  62.   //etc.
  63.  
  64.   //Serial.print("stripNumber ");
  65.   //Serial.print(stripNumber);
  66.   //Serial.print(" = ");
  67.   //Serial.println(L);
  68.   return L;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment