-
Notifications
You must be signed in to change notification settings - Fork 3
/
Experiment #1
165 lines (134 loc) · 3.7 KB
/
Experiment #1
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//Alternates with an if/then statement between pin 4 and pin 5 through a variable
//Experimenting with variations of the .h library. i.e. setPin, etc.
#include <FastSPI_LED.h>
int trigger = 1;
#define NUM_LEDS 10
// 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 aPin = 4;
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.setPinCount(8);
FastSPI_LED.setPin(4,4,4);
FastSPI_LED.setPin(5,5,4);
FastSPI_LED.init();
FastSPI_LED.start();
leds = (struct CRGB*)FastSPI_LED.getRGBData();
Serial.begin(9600);
Serial.println("serial");
}
void loop() {
if(trigger == 1){
interval = random(20,100);
// // one at a time
for(int j = 0; j < 4; j++) { //controls the number of cases
for(int i = 0 ; i < NUM_LEDS; i++ ) { //controls the number of LEDs on a strand
memset(leds, 0, NUM_LEDS * 3);//(LEDs array, constant brightness value, RGB components for NUM LEDs)
switch(j) {
case 0:
leds[i].b = 255;
leds[i].g = 0;
leds[i].r = 0;
break;
case 1:
leds[i].b = 0;
leds[i].g = 255;
leds[i].r = 0;
break;
case 2:
leds[i].b = 255;
leds[i].g = 255;
leds[i].r = 255;
break;
case 3:
leds[i].b = 0;
leds[i].g = 0;
leds[i].r = 255;
break;
}
FastSPI_LED.show();
delay(interval);
}
}
trigger = 1;
Serial.print("t is: ");
Serial.println( trigger, DEC);
}
else {
if(aPin == 4){
aPin = 5;
}else{
aPin = 4;
}
FastSPI_LED.setPin(aPin);
FastSPI_LED.init();
FastSPI_LED.start();
Serial.println("setLed");
trigger = 1;
}
//// 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);
// }
// }
}