Answer the question
In order to leave comments, you need to log in
Arduino ESP8266 how to make FastLED drive 2 different strips with 2 different effects at the same time?
Good day,
Tell me how to make the Arduino ESP8266 FastLED library control two different strips with 2 different effects at the same time?
The first tape (something like a white meteor runs in a circle, but there is a constant blue background)
The second tape is lit in blue and after 30 seconds. smoothly turns off for 5 seconds and turns on again for 30
I wrote the code, the first effect works, but as I add the second, the first one stops working, and the second one doesn’t at all.
Help to write correctly
#include "FastLED.h" // библиотека для работы с лентой
#define LED_COUNT_A 24 // число светодиодов в кольце/ленте
#define LED_COUNT_B 24 // число светодиодов в кольце/ленте2
#define LED_DA 22 // пин, куда подключен DIN 1 ленты
#define LED_DB 21 // пин, куда подключен DIN 2 ленты
#define del 50
int max_bright = 100; // максимальная яркость (0 - 255)
// ---------------СЛУЖЕБНЫЕ ПЕРЕМЕННЫЕ-----------------
int BOTTOM_INDEX = 0; // светодиод начала отсчёта
int TOP_INDEX = int(LED_COUNT_A / 2);
int EVENODD = LED_COUNT_A % 2;
struct CRGB leds_a[LED_COUNT_A];
struct CRGB leds_b[LED_COUNT_B];
int ledsX[LED_COUNT_A][3]; //-ARRAY FOR COPYING WHATS IN THE LED STRIP CURRENTLY (FOR CELL-AUTOMATA, MARCH, ETC)
int thishue = 0; //-FX LOOPS DELAY VAR
int thissat = 255; //-FX LOOPS DELAY VAR
int idex = 0; //-LED INDEX (0 to LED_COUNT_A-1
// ---------------СЛУЖЕБНЫЕ ПЕРЕМЕННЫЕ-----------------
void setup()
{
Serial.begin(9600); // открыть порт для связи
LEDS.setBrightness(max_bright); // ограничить максимальную яркость
LEDS.addLeds<WS2812B, LED_DA, GRB>(leds_a, LED_COUNT_A); // настрйоки для ленты A
LEDS.addLeds<WS2812B, LED_DB, GRB>(leds_b, LED_COUNT_B); // настрйоки для ленты B
LEDS.show(); // отослать команду
}
//------------------------LED EFFECT FUNCTIONS------------------------
void ems_lightsALL() {
idex++;
if (idex >= LED_COUNT_A) {
idex = 0;
}
int idexR = idex;
int idexB = antipodal_index(idexR-5);
int thathue = (thishue + 160) % 255;
leds_a[idexR] = CHSV(178, 221, 255); // color 1
leds_a[idexB] = CHSV(255, 10, 255); // color 2
LEDS.show();
delay(100);
}
void Scene_fade_down ()
{
for ( int i = 0; i < LED_COUNT_B; i++ )
{
leds_b[i] = CHSV(178, 221, 255);
leds_b[i].fadeToBlackBy( 64 );
}
FastLED.show();
delay(del);
}
//------------------------LED EFFECT FUNCTIONS------------------------
//---FIND INDEX OF HORIZONAL OPPOSITE LED
int horizontal_index(int i) {
//-ONLY WORKS WITH INDEX < TOPINDEX
if (i == BOTTOM_INDEX) {
return BOTTOM_INDEX;
}
if (i == TOP_INDEX && EVENODD == 1) {
return TOP_INDEX + 1;
}
if (i == TOP_INDEX && EVENODD == 0) {
return TOP_INDEX;
}
return LED_COUNT_A - i;
}
int antipodal_index(int i) {
int iN = i + TOP_INDEX;
if (i >= TOP_INDEX) {
iN = ( i + TOP_INDEX ) % LED_COUNT_A;
}
return iN;
}
//---FIND INDEX OF ANTIPODAL OPPOSITE LED
void loop() {
ems_lightsALL();
Scene_fade_down();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question