Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Libs
- #include "FastLED.h"
- #include <Wire.h>
- #include "BitBool.h"
- #include "XMas14_RGB.h"
- // Pin outs
- #define DATA_PIN 3
- // Define the array of leds and var declarations
- #define NUM_LEDS 50 // Change also in BitBool
- byte today, arrSize, arrElement;
- CRGB leds[NUM_LEDS];
- void setup() {
- Serial.begin(9600);
- Serial.println(F("XMas14 RGB Lights"));
- FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
- }
- void loop() {
- for (today = 0; today < 32; today++) {
- // Count amount of bits (1) in matrix for that row (today) and define the array size
- arrSize = 0;
- for (byte i = 0; i < 50; i++) {
- if (matrix[today][i] == 1) {
- arrSize++;
- }
- }
- byte numArray[arrSize];
- Serial.print(F("Displaying number: "));
- Serial.print(today);
- Serial.print(F(" (array size "));
- Serial.print(arrSize);
- Serial.println(F(")"));
- // Fill the LED number into the defined array.
- // Array element 0 is LED 1, element 49 is LED 50, and so on!
- Serial.print(F("LEDS: "));
- arrElement = 0;
- for (byte i = 0; i < NUM_LEDS; i++) {
- if (matrix[today][i] == 1) {
- numArray[arrElement] = i ;
- Serial.print(numArray[arrElement]); Serial.print(F(" "));
- arrElement++;
- }
- }
- Serial.println(F(""));Serial.println(F("---------------------")); // Separator
- delay(100);FastLED.clear();delay(100);
- for (byte led = 0; led < arrSize; led++) {
- leds[numArray[led]] = CHSV(128,255,255);
- }
- FastLED.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement