Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1751 | - | 1 | #include "LPD8806_kopterlight.h" |
2 | #include "SPI.h" |
||
3 | |||
4 | /*****************************************************************************/ |
||
5 | // Kopter light control on LPD8806-based RGB LED Modules in a strip! |
||
6 | /*****************************************************************************/ |
||
7 | |||
8 | /*****************************************************************************/ |
||
9 | // To be changed according to your setup |
||
10 | // The LED strips are 40 LEDs per meter but you can extend/cut the strip |
||
11 | |||
12 | #define rigger 4 // number of rigger (default: 4) |
||
13 | #define riggerSize 10 // Pixels / LEDs per rigger (default: 10) |
||
14 | |||
15 | #define stripSize (riggerSize*rigger) |
||
16 | |||
17 | // Use only if Hardware SPI is not possible |
||
18 | // int dataPin = 3; // Software SPI Data Pin |
||
19 | // int clockPin = 2; // Software SPI Clock Pin |
||
20 | // Soft SPI |
||
21 | // LPD8806 strip = LPD8806(stripSize, dataPin, clockPin, rigger); |
||
22 | |||
23 | // HW SPI |
||
24 | // on Arduino 168/328 thats data = 11, and clock = pin 13 |
||
25 | LPD8806 strip = LPD8806(stripSize, rigger); |
||
26 | |||
27 | /*****************************************************************************/ |
||
28 | //Do not change or remove these! |
||
29 | void setup() { |
||
30 | // Start up the LED strip |
||
31 | strip.begin(); |
||
32 | // Update the strip, to start they are all 'off' |
||
33 | strip.show(); |
||
34 | } |
||
35 | |||
36 | /*****************************************************************************/ |
||
37 | // Space for your light effects: |
||
38 | /*****************************************************************************/ |
||
39 | // Only inside Void Loop() you are allowed to design your light effects !! |
||
40 | // ( If you like to program a new pattern or sequences, refer to sequences.ino) |
||
41 | /*****************************************************************************/ |
||
42 | // Parameter: Colors are defined by the additive RGB color model. |
||
43 | // n = LED No on rigger |
||
44 | // r = red ( max. 127) |
||
45 | // g = green ( max. 127) |
||
46 | // b = blue ( max. 127) |
||
47 | // dly = delay ( typical: 10 - 50 ) |
||
48 | // cyl = cyles ( how many times this sequence will repeat ) |
||
49 | // riX = rigger to set pixel / to show sequence on x= number of rigger |
||
50 | /*****************************************************************************/ |
||
51 | void loop() { |
||
52 | |||
53 | clearstrip (); |
||
54 | |||
55 | // These are Examples of possible color pattern and sequences. |
||
56 | |||
57 | // Set single LED on selected rigger: |
||
58 | // setLED(n, r, g, b, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
59 | setLED(1, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); |
||
60 | strip.show(); |
||
61 | delay(550); |
||
62 | setLED(10, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); |
||
63 | strip.show(); |
||
64 | delay(550); |
||
65 | setLED(10, 0, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0); |
||
66 | strip.show(); |
||
67 | delay(550); |
||
68 | setLED(1, 0, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0); |
||
69 | strip.show(); |
||
70 | delay(550); |
||
71 | setLED(1, 0, 0, 127, 0, 0, 1, 0, 0, 0, 0, 0); |
||
72 | strip.show(); |
||
73 | delay(550); |
||
74 | setLED(10, 0, 0,127, 0, 0, 1, 0, 0, 0, 0, 0); |
||
75 | strip.show(); |
||
76 | delay(550); |
||
77 | setLED(10, 127, 127, 127, 0, 0, 0, 1, 0, 0, 0, 0); |
||
78 | strip.show(); |
||
79 | delay(550); |
||
80 | setLED(1, 127, 127, 127, 0, 0, 0, 1, 0, 0, 0, 0); |
||
81 | strip.show(); |
||
82 | delay(550); |
||
83 | setLED(5, 127, 52, 0, 1, 1, 1, 1, 0, 0, 0, 0); |
||
84 | setLED(6, 127, 52, 0, 1, 1, 1, 1, 0, 0, 0, 0); |
||
85 | strip.show(); |
||
86 | delay(550); |
||
87 | clearstrip (); |
||
88 | strip.show(); |
||
89 | delay(950); |
||
90 | setLED(5, 127, 52, 0, 1, 1, 1, 1, 0, 0, 0, 0); |
||
91 | setLED(6, 127, 52, 0, 1, 1, 1, 1, 0, 0, 0, 0); |
||
92 | strip.show(); |
||
93 | delay(950); |
||
94 | clearstrip (); |
||
95 | strip.show(); |
||
96 | |||
97 | // Fade In Effect: |
||
98 | // fadein(r, g, b, dly, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
99 | fadein(127,14,0,10,1,0,1,0,0,0,0,0); |
||
100 | |||
101 | // Fade Out Effect: |
||
102 | // fadein(r,g,b,dly,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
103 | fadeout(127,14,0,10,1,0,1,0,0,0,0,0); |
||
104 | |||
105 | fadein(127,0,0,10,0,1,0,1,0,0,0,0); |
||
106 | fadeout(127,0,0,10,0,1,0,1,0,0,0,0); |
||
107 | fadein(47,127,00,5,1,0,0,0,0,0,0,0); |
||
108 | fadein(47,127,00,5,0,1,0,0,0,0,0,0); |
||
109 | fadein(47,127,00,5,0,0,1,0,0,0,0,0); |
||
110 | fadein(47,127,00,5,0,0,0,1,0,0,0,0); |
||
111 | fadeout(47,127,00,5,1,0,0,0,0,0,0,0); |
||
112 | fadeout(47,127,00,5,0,1,0,0,0,0,0,0); |
||
113 | fadeout(47,127,00,5,0,0,1,0,0,0,0,0); |
||
114 | fadeout(47,127,00,5,0,0,0,1,0,0,0,0); |
||
115 | fadein(0,0,127,2,1,0,0,0,0,0,0,0); |
||
116 | fadein(0,0,127,2,0,0,0,1,0,0,0,0); |
||
117 | fadein(0,0,127,2,0,0,1,0,0,0,0,0); |
||
118 | fadein(0,0,127,2,0,1,0,0,0,0,0,0); |
||
119 | fadeout(0,0,127,2,0,1,0,0,0,0,0,0); |
||
120 | fadeout(0,0,127,2,0,0,1,0,0,0,0,0); |
||
121 | fadeout(0,0,127,2,0,0,0,1,0,0,0,0); |
||
122 | fadeout(0,0,127,2,1,0,0,0,0,0,0,0); |
||
123 | |||
124 | // Flashing Light Effect ( yellow-orange ) |
||
125 | // flashLight(dly,cyl,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
126 | flashLight(100,3,1,1,1,1,0,0,0,0); |
||
127 | flashLight(100,3,1,0,1,0,0,0,0,0); |
||
128 | flashLight(100,3,0,1,0,1,0,0,0,0); |
||
129 | |||
130 | // Police Light Effect ( green & orange ) |
||
131 | // police(dly,cyl,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8); |
||
132 | police(110,3,1,0,0,0,0,0,0,0); |
||
133 | police(110,3,0,1,0,0,0,0,0,0); |
||
134 | police(110,3,0,0,1,0,0,0,0,0); |
||
135 | police(110,3,0,0,0,1,0,0,0,0); |
||
136 | police(110,3,1,0,1,0,0,0,0,0); |
||
137 | police(110,3,0,1,0,1,0,0,0,0); |
||
138 | police(110,3,0,0,1,1,0,0,0,0); |
||
139 | police(110,3,1,1,0,0,0,0,0,0); |
||
140 | police(110,3,0,1,1,0,0,0,0,0); |
||
141 | police(110,3,1,0,0,1,0,0,0,0); |
||
142 | police(110,3,1,1,1,1,0,0,0,0); |
||
143 | |||
144 | // Circling Lights Effect ( red & blue ) |
||
145 | // circlinglights(dly,cyl,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8); |
||
146 | circlinglights(40,3,1,1,1,1,0,0,0,0); |
||
147 | circlinglights(40,3,1,0,0,0,0,0,0,0); |
||
148 | circlinglights(40,3,0,1,0,0,0,0,0,0); |
||
149 | circlinglights(40,3,0,0,1,0,0,0,0,0); |
||
150 | circlinglights(40,3,0,0,0,1,0,0,0,0); |
||
151 | |||
152 | // Send a simple pixel chase in... |
||
153 | // colorChase(r,g,b,dly,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
154 | colorChase(127,127,127,80,1,0,0,0,0,0,0,0); // white |
||
155 | |||
156 | // colorChaseRev(r,g,b,dly,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
157 | colorChaseRev(127,0,0,80,0,1,0,0,0,0,0,0); // red |
||
158 | |||
159 | colorChase(127,127,0,80,0,0,1,0,0,0,0,0); // yellow |
||
160 | colorChaseRev(0,127,0,80,0,0,0,1,0,0,0,0); // green |
||
161 | colorChase(0,127,127,80,1,0,1,0,0,0,0,0); // cyan |
||
162 | colorChaseRev(0,0,127,80,0,1,0,1,0,0,0,0); // blue |
||
163 | colorChase(127,0,127,80,1,1,1,1,0,0,0,0); // magenta |
||
164 | |||
165 | // Fill the entire strip with... |
||
166 | // colorWipe(r,g,b,dly,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
167 | colorWipe(0,0,127,30,1,0,0,0,0,0,0,0); // blue |
||
168 | colorWipe(127,0,43,30,0,1,0,0,0,0,0,0); // vibrant purple |
||
169 | colorWipe(4,127,55,30,0,0,1,0,0,0,0,0); // vibrant green |
||
170 | colorWipe(127,50,0,30,0,0,0,1,0,0,0,0); // orange |
||
171 | colorWipe(0,0,0,30,1,1,1,1,0,0,0,0); // black |
||
172 | |||
173 | // Color sparkles |
||
174 | dither(0,127,127, 70,1,0,1,0,0,0,0,0); // cyan, slow |
||
175 | dither(0,0,0, 70,1,0,1,0,0,0,0,0); // black, fast |
||
176 | dither(127,0,127, 70,1,1,1,1,0,0,0,0); // magenta, slow |
||
177 | dither(0,0,0, 70,1,1,1,1,0,0,0,0); // black, fast |
||
178 | dither(127,127,0, 70,0,1,0,1,0,0,0,0); // yellow, slow |
||
179 | dither(0,0,0, 70,0,1,0,1,0,0,0,0); // black, fast |
||
180 | |||
181 | // Back-and-forth lights |
||
182 | // scanner(r,g,b,dly,ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
183 | scanner(127,52,0, 50,1,0,0,0,0,0,0,0); // orange, fast |
||
184 | scanner(127,0,0, 50,0,0,1,0,0,0,0,0); // red, slow |
||
185 | scanner(0,0,127, 50,0,1,0,1,0,0,0,0); // blue, medium |
||
186 | |||
187 | // Wavy ripple effects |
||
188 | // wave(r,g,b,dly, stp, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
189 | wave(127,0,0, 50, 4,1,0,1,0,0,0,0,0); // candy |
||
190 | clearstrip (); |
||
191 | wave(0,0,127, 50, 3,0,1,0,1,0,0,0,0); // icy |
||
192 | clearstrip (); |
||
193 | wave(0,127,0, 50, 2,1,0,1,0,0,0,0,0); // nature |
||
194 | clearstrip (); |
||
195 | |||
196 | // make a pretty rainbow cycle! |
||
197 | // rainbowCycle(dly, cyl, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8) |
||
198 | rainbowCycle(0,3,1,0,0,0,0,0,0,0); // make it go through the cycle fairly fast |
||
199 | rainbowCycle(0,3,1,0,1,0,0,0,0,0); // make it go through the cycle fairly fast |
||
200 | clearstrip (); |
||
201 | rainbowCycle(0,3,0,1,0,1,0,0,0,0); // make it go through the cycle fairly fast |
||
202 | rainbowCycle(0,8,1,1,1,1,0,0,0,0); // make it go through the cycle fairly fast |
||
203 | |||
204 | |||
205 | |||
206 | |||
207 | } |
||
208 | /*****************************************************************************/ |
||
209 | |||
210 | |||
211 | |||
212 |