Camila_99$$
Camila_99$$
DIIDevHeads IoT Integration Server
Created by Camila_99$$ on 5/30/2024 in #middleware-and-os
How to Synchronize Two LED Strip Effects to Start Simultaneously?
#include <FastLED.h> #define NUM_LEDS_BAND1 132 #define NUM_LEDS_BAND2 96 #define DATA_PIN_BAND1 2 #define DATA_PIN_BAND2 3 CRGB leds_band1[NUM_LEDS_BAND1]; CRGB leds_band2[NUM_LEDS_BAND2]; void setup() { FastLED.addLeds<WS2812B, DATA_PIN_BAND1, RGB>(leds_band1, NUM_LEDS_BAND1); FastLED.addLeds<WS2812B, DATA_PIN_BAND2, RGB>(leds_band2, NUM_LEDS_BAND2); } void loop() { static uint8_t brightness = 0; static uint8_t chaseIndex = 0; idle(leds_band1, NUM_LEDS_BAND1, brightness); chenillard(leds_band2, NUM_LEDS_BAND2, chaseIndex); FastLED.show(); delay(15); brightness = (brightness < 51) ? brightness + 1 : 51; chaseIndex = (chaseIndex < NUM_LEDS_BAND2) ? chaseIndex + 1 : 0; } void idle(CRGB leds1[], int numLEDs1, uint8_t brightness) { FastLED.setBrightness(brightness); for (int i = 0; i < numLEDs1; i++) { leds1[i] = CRGB(46, 51, 36); } } void chenillard(CRGB leds2[], int numLEDs2, uint8_t chaseIndex) { for (int i = 0; i < numLEDs2; i++) { if (i == chaseIndex) { leds2[i] = CRGB(0, 51, 36); } else { leds2[i] = CRGB::Black; } } }
8 replies