Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1.  
  2. // Libs
  3. #include "FastLED.h"
  4. #include <Wire.h>
  5. #include "BitBool.h"
  6. #include "XMas14_RGB.h"
  7.  
  8. // Pin outs
  9. #define DATA_PIN 3
  10.  
  11. // Define the array of leds and var declarations
  12. #define NUM_LEDS 50 // Change also in BitBool
  13. byte today, arrSize, arrElement;
  14. CRGB leds[NUM_LEDS];
  15.  
  16. void setup() {
  17.   Serial.begin(9600);
  18.   Serial.println(F("XMas14 RGB Lights"));
  19.  
  20.   FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  21. }
  22.  
  23. void loop() {
  24.   for (today = 0; today < 32; today++) {
  25.  
  26.     // Count amount of bits (1) in matrix for that row (today) and define the array size
  27.     arrSize = 0;
  28.     for (byte i = 0; i < 50; i++) {
  29.       if (matrix[today][i] == 1) {
  30.         arrSize++;
  31.       }  
  32.     }
  33.     byte numArray[arrSize];
  34.  
  35.     Serial.print(F("Displaying number: "));
  36.     Serial.print(today);    
  37.     Serial.print(F(" (array size "));
  38.     Serial.print(arrSize);
  39.     Serial.println(F(")"));
  40.  
  41.     // Fill the LED number into the defined array.
  42.     // Array element 0 is LED 1, element 49 is LED 50, and so on!
  43.     Serial.print(F("LEDS: "));
  44.     arrElement = 0;
  45.     for (byte i = 0; i < NUM_LEDS; i++) {
  46.       if (matrix[today][i] == 1) {
  47.         numArray[arrElement] = i ;
  48.         Serial.print(numArray[arrElement]); Serial.print(F(" "));
  49.         arrElement++;
  50.       }
  51.     }
  52.     Serial.println(F(""));Serial.println(F("---------------------")); // Separator
  53.  
  54.     delay(100);FastLED.clear();delay(100);
  55.      
  56.     for (byte led = 0; led < arrSize; led++) {
  57.       leds[numArray[led]] = CHSV(128,255,255);
  58.     }
  59.     FastLED.show();  
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement