Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The goal of this test sketch is to run multiple strips where each dot could be turned on one after the other but with different times on/off between each pixel on each strip.
- By: Andrew Tuline
- Date: August, 2015
- Assumptions:
- - Each element in the array is greater than the one previous.
- - The last element in the array is the end of the line.
- Note that there are NO nasty 'for' or blocking delays.
- */
- #include <FastLED.h>
- #define NUM_LEDS1 10
- #define NUM_LEDS2 6
- // Define pin (each strip be connected on)
- #define DATA_PIN1 5
- #define DATA_PIN2 6
- uint8_t fadeval = 128;
- // Declare the strips
- CRGB leds1[NUM_LEDS1];
- CRGB leds2[NUM_LEDS2];
- // Each element in the array is a time in ms %( the last element) to turn on.
- // Example : strip1= pixel_0:100ms, pixel_1:200ms, pixel_2:300ms, pixel_3:400ms, pixel_4:500ms, pixel_5:600ms, pixel_6:700ms, pixel_7:800ms, pixel_8:900ms, pixel_9:1000ms
- int dot_delay1[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
- int dot_delay2[] = {100, 200, 300, 400, 500, 600};
- void setup() {
- Serial.begin(57600);
- FastLED.addLeds<NEOPIXEL, DATA_PIN1>(leds1, NUM_LEDS1);
- FastLED.addLeds<NEOPIXEL, DATA_PIN2>(leds2, NUM_LEDS2);
- } // setup()
- void loop() {
- static int counter1 = 0;
- static int counter2 = 0;
- if (dot_delay1[counter1] - millis()%1000 < 5) {leds1[counter1] = CRGB::Blue; counter1 = (counter1+1) % (NUM_LEDS1);}
- if (dot_delay2[counter2] - millis()%600 < 5) {leds2[counter2] = CRGB::Blue; counter2 = (counter2+1) % (NUM_LEDS2); }
- FastLED.show();
- fadeToBlackBy(leds1, NUM_LEDS1, fadeval); // 8 bit, 1 = slow, 255 = fast
- fadeToBlackBy(leds2, NUM_LEDS2, fadeval); // 8 bit, 1 = slow, 255 = fast
- } // loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement