-
Notifications
You must be signed in to change notification settings - Fork 3
/
Code
128 lines (109 loc) · 2.98 KB
/
Code
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*Pin4 steady repeat led runs with random speeds. Mashup of Maxbotics ultrasonic
sensor to trigger LEDs*/
#include <FastSPI_LED.h>
#define NUM_LEDS 30
// Sometimes chipsets wire in a backwards sort of way
struct CRGB {
unsigned char b;
unsigned char r;
unsigned char g;
};
//struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;
#define FOUR 4
//#define FIVE 5
int interval = 0;
void setup()
{
FastSPI_LED.setLeds(NUM_LEDS);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_SM16716);
FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
//FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);
FastSPI_LED.setPin(FOUR);
FastSPI_LED.init();
FastSPI_LED.start();
leds = (struct CRGB*)FastSPI_LED.getRGBData();
}
void loop() {
interval = random(20,100);
// // one at a time
for(int j = 0; j < 3; j++) {
for(int i = 0 ; i < NUM_LEDS; i++ ) {
memset(leds, 0, NUM_LEDS * 3);
switch(j) {
case 0:
leds[i].b = 255;
leds[i].g = 255;
leds[i].r = 255;
break;
case 1:
leds[i].b = 255;
leds[i].g = 255;
leds[i].r = 255;
break;
case 2:
leds[i].b = 255;
leds[i].g = 255;
leds[i].r = 255;
break;
}
FastSPI_LED.show();
delay(interval);
}
// FastSPI_LED.setPin(FIVE);
// FastSPI_LED.init();
// FastSPI_LED.start();
}
//// growing/receeding bars
// for(int j = 0; j < 3; j++) {
// memset(leds, 0, NUM_LEDS * 3);
// for(int i = 0 ; i < NUM_LEDS; i++ ) {
// switch(j) {
// case 0: leds[i].r = 255; break;
// case 1: leds[i].g = 255; break;
// case 2: leds[i].b = 255; break;
// }
// FastSPI_LED.show();
// delay(10);
// }
// for(int i = NUM_LEDS-1 ; i >= 0; i-- ) {
// switch(j) {
// case 0: leds[i].r = 0; break;
// case 1: leds[i].g = 0; break;
// case 2: leds[i].b = 0; break;
// }
// FastSPI_LED.show();
// delay(1);
// }
// }
//
// // Fade in/fade out
// for(int j = 0; j < 3; j++ ) {
// memset(leds, 0, NUM_LEDS * 3);
// for(int k = 0; k < 256; k++) {
// for(int i = 0; i < NUM_LEDS; i++ ) {
// switch(j) {
// case 0: leds[i].r = k; break;
// case 1: leds[i].g = k; break;
// case 2: leds[i].b = k; break;
// }
// }
// FastSPI_LED.show();
// delay(3);
// }
// for(int k = 255; k >= 0; k--) {
// for(int i = 0; i < NUM_LEDS; i++ ) {
// switch(j) {
// case 0: leds[i].r = k; break;
// case 1: leds[i].g = k; break;
// case 2: leds[i].b = k; break;
// }
// }
// FastSPI_LED.show();
// delay(3);
// }
// }
}