9 const int fadelimit = 3000;
10 const int fadelimitshort = 1000;
13 boolean changemode = 0;
15 const int rainlimit = 5000;
16 const int rainfade = 5000;
20 // pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
22 -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 14, 15, 18, 19, 20, 21
25 // col[xx] of leds = pin yy on led matrix
27 pins[8], pins[7], pins[6], pins[5], pins[9], pins[10], pins[11], pins[12], pins[13], pins[14], pins[15], pins[16]
30 // row[xx] of leds = pin yy on led matrix
32 pins[1], pins[2], pins[3], pins[4]
37 extern byte leds[12][4];
42 for (int s = 0; s < 5; s++) {
43 for ( int r = 1; r < 9; r++) {
44 delayMicroseconds(65000);
45 delayMicroseconds(65000);
46 for (int j = 0; j < 4; j++) {
47 for (int i = 0; i < 12; i++) {
49 for (int p = 0; p < 25; p++) {
55 for ( int r = 9; r > 0; r--) {
56 delayMicroseconds(65000);
57 delayMicroseconds(65000);
58 delayMicroseconds(65000);
59 for (int j = 0; j < 4; j++) {
60 for (int i = 0; i < 12; i++) {
62 for (int p = 0; p < 25; p++) {
76 for (int i = 0; i < 12; i++) {
77 for (int j = 0; j < 4; j++) {
78 leds[i][j] = brightness;
85 for ( int r = 1; r < 9; r++) {
87 if (changemode == 0) {
88 delayMicroseconds(65000);
89 delayMicroseconds(65000);
90 delayMicroseconds(65000);
91 for (int j = 0; j < 4; j++) {
92 for (int i = 0; i < 12; i++) {
94 for (int p = 0; p < 25; p++) {
104 for ( int r = 9; r > 0; r--) {
106 if (changemode == 0) {
107 delayMicroseconds(65000);
108 delayMicroseconds(65000);
109 delayMicroseconds(65000);
110 delayMicroseconds(65000);
111 for (int j = 0; j < 4; j++) {
112 for (int i = 0; i < 12; i++) {
114 for (int p = 0; p < 25; p++) {
124 for ( int r = 1; r < 30; r++) {
126 if (changemode == 0) {
127 delayMicroseconds(65000);
128 delayMicroseconds(65000);
137 leds[random(12)][random(4)] = random(8);
138 delayMicroseconds(10000);
144 if (rain > rainlimit) {
148 if (leds[rx][ry] == 0) {
153 if (fadecount > rainfade) {
155 for (int i = 0; i < 12; i++) {
156 for (int j = 0; j < 4; j++) {
157 if (leds[i][j] > 0) {
158 leds[i][j] = leds[i][j] - 1;
168 if (fadecount > fadelimit) {
170 for (int i = 0; i < 12; i++) {
171 for (int j = 0; j < 4; j++) {
172 if (leds[i][j] > 0) {
173 leds[i][j] = leds[i][j] - 1;
183 if (fadecount > fadelimitshort) {
185 for (int i = 0; i < 12; i++) {
186 for (int j = 0; j < 4; j++) {
187 if (leds[i][j] > 0) {
188 leds[i][j] = leds[i][j] - 1;
203 if (Serial1.available() > 0) {
204 iByte = Serial1.read();
207 if (brightness > 9) {
216 byte row = iByte / 16;
217 byte col = iByte % 16;
221 byte row = iByte / 16;
222 byte col = iByte % 16;
223 for (byte i = 0; i < 12; i++) {
226 for (byte p = 0; p < 4; p++) {
235 // sets the pins as output
236 FastGPIO::Pin<2>::setOutputLow();
237 FastGPIO::Pin<3>::setOutputLow();
238 FastGPIO::Pin<4>::setOutputLow();
239 FastGPIO::Pin<5>::setOutputLow();
240 FastGPIO::Pin<6>::setOutputLow();
241 FastGPIO::Pin<7>::setOutputLow();
242 FastGPIO::Pin<8>::setOutputLow();
243 FastGPIO::Pin<9>::setOutputLow();
244 FastGPIO::Pin<10>::setOutputLow();
245 FastGPIO::Pin<16>::setOutputLow();
246 FastGPIO::Pin<14>::setOutputLow();
247 FastGPIO::Pin<15>::setOutputLow();
248 FastGPIO::Pin<18>::setOutputLow();
249 FastGPIO::Pin<19>::setOutputLow();
250 FastGPIO::Pin<20>::setOutputLow();
251 FastGPIO::Pin<21>::setOutputLow();
254 FastGPIO::Pin<6>::setOutputValueLow();
255 FastGPIO::Pin<7>::setOutputValueLow();
256 FastGPIO::Pin<8>::setOutputValueLow();
257 FastGPIO::Pin<9>::setOutputValueLow();
258 FastGPIO::Pin<10>::setOutputValueLow();
259 FastGPIO::Pin<16>::setOutputValueLow();
260 FastGPIO::Pin<14>::setOutputValueLow();
261 FastGPIO::Pin<15>::setOutputValueLow();
262 FastGPIO::Pin<18>::setOutputValueLow();
263 FastGPIO::Pin<19>::setOutputValueLow();
264 FastGPIO::Pin<20>::setOutputValueLow();
265 FastGPIO::Pin<21>::setOutputValueLow();
268 FastGPIO::Pin<2>::setOutputValueLow();
269 FastGPIO::Pin<3>::setOutputValueLow();
270 FastGPIO::Pin<4>::setOutputValueLow();
271 FastGPIO::Pin<5>::setOutputValueLow();
274 Timer1.initialize(25);
275 Timer1.attachInterrupt(display);
280 // Clear display array
281 for (int i = 0; i < 12; i++) {
282 for (int j = 0; j < 4; j++) {
289 // Clear display array
290 for (int i = 0; i < 12; i++) {
291 for (int j = 0; j < 4; j++) {
300 switch (col) { // Turn whole previous column off
302 FastGPIO::Pin<6>::setOutputValueLow();
305 FastGPIO::Pin<7>::setOutputValueLow();
308 FastGPIO::Pin<8>::setOutputValueLow();
311 FastGPIO::Pin<9>::setOutputValueLow();
314 FastGPIO::Pin<10>::setOutputValueLow();
317 FastGPIO::Pin<16>::setOutputValueLow();
320 FastGPIO::Pin<14>::setOutputValueLow();
323 FastGPIO::Pin<15>::setOutputValueLow();
326 FastGPIO::Pin<18>::setOutputValueLow();
329 FastGPIO::Pin<19>::setOutputValueLow();
332 FastGPIO::Pin<20>::setOutputValueLow();
335 FastGPIO::Pin<21>::setOutputValueLow();
347 for (int row = 0; row < 4; row++) {
348 if (leds[col][row] > pass) {
349 switch (row) { // Turn on this led
351 FastGPIO::Pin<2>::setOutputValueLow();
354 FastGPIO::Pin<3>::setOutputValueLow();
357 FastGPIO::Pin<4>::setOutputValueLow();
360 FastGPIO::Pin<5>::setOutputValueLow();
365 switch (row) { // Turn off this led
367 FastGPIO::Pin<2>::setOutputValueHigh();
370 FastGPIO::Pin<3>::setOutputValueHigh();
373 FastGPIO::Pin<4>::setOutputValueHigh();
376 FastGPIO::Pin<5>::setOutputValueHigh();
381 switch (col) { // Turn column on
383 FastGPIO::Pin<6>::setOutputValueHigh();
386 FastGPIO::Pin<7>::setOutputValueHigh();
389 FastGPIO::Pin<8>::setOutputValueHigh();
392 FastGPIO::Pin<9>::setOutputValueHigh();
395 FastGPIO::Pin<10>::setOutputValueHigh();
398 FastGPIO::Pin<16>::setOutputValueHigh();
401 FastGPIO::Pin<14>::setOutputValueHigh();
404 FastGPIO::Pin<15>::setOutputValueHigh();
407 FastGPIO::Pin<18>::setOutputValueHigh();
410 FastGPIO::Pin<19>::setOutputValueHigh();
413 FastGPIO::Pin<20>::setOutputValueHigh();
416 FastGPIO::Pin<21>::setOutputValueHigh();