-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ino
More file actions
67 lines (59 loc) · 1.93 KB
/
Copy pathmain.ino
File metadata and controls
67 lines (59 loc) · 1.93 KB
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
#include <FastLED.h>
#define LED_PIN 10
#define NUM_LEDS 47
CRGB leds[NUM_LEDS];
int R = 0;
int G = 0;
int B = 0;
int len = 0;
int num = 0;
//num is number seperate led segments used in a squence
//len is lenght of a sequence (in leds)
//R G B are color values for the sequence
//pos is a 2d array where every row is a led segment and every column has only 2 value,
//first one is a number of starting led, and the second column has the direction (0 = forward, 1 = backwards)
void chase(int num, int len, int R, int G, int B, int pos[][2]) {
//repeat for lenght of a sequence
for (int i = 0; i<len; i++) {
//repeat for every segment of leds
for (int j = 0; j < num; j++){
//determine if sequence is going "forward"
if (pos[j][1] == 0) {
leds[pos[j][0]+i] = CRGB(R, G, B);
leds[pos[j][0]+i-2] = CRGB(0, 0, 0);
} else {
leds[pos[j][0]+len-i] = CRGB(R, G, B);
leds[pos[j][0]+len-i+2] = CRGB(0, 0, 0);
};
};
FastLED.show();
delay(300);
}
FastLED.clear();
FastLED.show();
};
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<WS2811, LED_PIN, BRG>(leds, NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
FastLED.clear();
FastLED.show();
}
void loop() {
// put your main code here, to run repeatedly:
int pos[3][2] = {{0, 0},{14, 1},{19, 0}};
chase(3, 5, 255, 255, 255,pos);
int pos1[4][2] = {{5, 0},{9, 1},{25, 0},{29, 1}};
chase(4, 5, 255, 255, 255,pos1);
int pos2[2][2] = {{35, 0},{39, 1}};
chase(2, 5, 255, 255, 255,pos2);
int pos4[2][2] = {{34, 1},{40, 0}};
chase(2, 5, 255, 255, 255,pos4);
int pos5[4][2] = {{4, 1},{10, 0},{24, 1},{30, 0}};
chase(4, 5, 255, 255, 255,pos5);
int pos3[3][2] = {{-1, 1},{15, 0},{19, 1}};
chase(3, 5, 255, 255, 255,pos3);
//test pattern
//int postest[9][2] = {{0, 0},{5, 0},{10, 0},{15, 0},{20, 0},{25, 0},{30, 0},{35, 0},{40, 0}};
//chase(9, 5, 255, 255, 255,postest);
}