Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The goal of the sketch is to run multiple strip where each dot could be controled on/off one after the others but with different times on/off between each pixel on each strip
- // All be indepandant and separate and automated and structured allready like FastLED library recommandation.
- // Library include
- #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
- // Declare some strip name and attribute (number of led per strip)
- CRGB leds1[NUM_LEDS1];
- CRGB leds2[NUM_LEDS2];
- void setup() {
- FastLED.addLeds<NEOPIXEL, DATA_PIN1>(leds1, NUM_LEDS1);
- FastLED.addLeds<NEOPIXEL, DATA_PIN2>(leds2, NUM_LEDS2);
- }
- // This is where i put some value for indicate ''delay'' time in millisecond for each strip
- // Example : dot_delay1 is for strip1 and every value is regardless about how much time each pixel/led in each strip be lighted before going to the second one
- // 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
- // note then number of value in array = NUM_LEDSX
- int dot_delay1[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
- int dot_delay2[] = {100, 200, 300, 400, 500, 600};
- void loop() {
- // This is where i tell to go one dot/pixel to another for each strip/num_led
- for (int dot = 0; dot < NUM_LEDS1; dot++) {
- for (int dot = 0; dot < NUM_LEDS2; dot++) {
- // This is where i said every dot going to be blue
- leds1[dot] = CRGB::Blue;
- leds2[dot] = CRGB::Blue;
- // Show led statut
- FastLED.show();
- // This is where i said every dot going to be black
- leds1[dot] = CRGB::Black;
- leds2[dot] = CRGB::Black;
- // Store current time in previousMillis variable
- unsigned long previousMillis = millis();
- // Create boolean variables to monitor if the first strip and second strip have triggered yet
- bool delayFlag1 = false, delayFlag2 = false;
- // Loop continuously
- while (1) {
- // If the first delay time has passed, delayFlag1 is true
- if ((unsigned long)(millis() - previousMillis) >= dot_delay1[dot]) {
- delayFlag1 = true;
- }
- // If the second delay time has passed, delayFlag2 is true
- if ((unsigned long)(millis() - previousMillis) >= dot_delay2[dot]) {
- delayFlag2 = true;
- }
- // If both delay times have passed (both delay flags are true), exit while loop
- if ((delayFlag1 && delayFlag2) == true) {
- return;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment