forked from marmilicious/FastLED_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ArrayOfLedArrays.ino
68 lines (53 loc) · 1.76 KB
/
test_ArrayOfLedArrays.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ArrayOfLedArrays with strips of different length test
// Marc Miller, Apr 2016
//---------------------------------------------------------------
#include "FastLED.h"
#define LED_TYPE NEOPIXEL
#define NUM_STRIPS 3 // Total number of strips
#define NUM_LEDS 12 // Specify length of each strip
#define NUM_LEDS1 32
#define NUM_LEDS2 30
//etc.
CRGB leds[NUM_STRIPS][NUM_LEDS + NUM_LEDS1 + NUM_LEDS2]; // Add all together here
uint8_t stripLength; // Used to store a strip length.
//---------------------------------------------------------------
void setup() {
Serial.begin(115200); // Allows serial monitor output (check baud rate)
delay(3000);
FastLED.addLeds<LED_TYPE, 6>(leds[0], NUM_LEDS); // Assign data pins
FastLED.addLeds<LED_TYPE, 11>(leds[1], NUM_LEDS1);
FastLED.addLeds<LED_TYPE, 13>(leds[2], NUM_LEDS2);
//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_LEDS; }
if (stripNumber == 1) { L = NUM_LEDS1; }
if (stripNumber == 2) { L = NUM_LEDS2; }
//etc.
//Serial.print("stripNumber ");
//Serial.print(stripNumber);
//Serial.print(" = ");
//Serial.println(L);
return L;
}