// For: https://forum.arduino.cc/t/controlling-multiple-strips-of-ws2812b-backlight/988305/
//
// Version 1, 4 May 2022, by Koepel, Public Domain
// Version 2, 5 May 2022, by Koepel, Public Domain
// A few fixes from the Discord channel to make it work.
//
// In Real Life, a amplifier/buffer is needed to pump up the signal from the ESP32.
//
// Note:
// Wokwi has trouble at the moment with ESP32 + ledstrips.
// Added extra attribute to ESP32 in diagram.json:
// "attrs": { "__timingOptimizations": "disable" }
// Using delay() instead of FastLED.delay().
// This will also solve the problem:
// A #define FASTLED_RMT_BUILTIN_DRIVER 1 before the include using [email protected]
//
#include <FastLED.h>
#define NUM_LEDS 100 // 100 per panel
#define NUM_PANELS 2
const int dataPin[NUM_PANELS] = { 18, 5}; // not used, the addLeds needs const_expr
CRGB leds[NUM_PANELS][NUM_LEDS];
int count;
void setup()
{
FastLED.addLeds<NEOPIXEL, 18>(leds[0], NUM_LEDS); // assuming GRB order
FastLED.addLeds<NEOPIXEL, 5>(leds[1], NUM_LEDS); // assuming GRB order
// Set left panel to a color
fill_solid(leds[0], NUM_LEDS, CRGB::Green);
}
void loop()
{
// Set right panel to an changing color
switch( count)
{
case 0:
fill_solid(leds[1], NUM_LEDS, CRGB::Orchid);
break;
case 1:
fill_solid(leds[1], NUM_LEDS, CRGB::MidnightBlue);
break;
case 2:
fill_solid(leds[1], NUM_LEDS, CRGB::Orange);
break;
case 3:
// Random for every pixel
for( int i=0; i<NUM_LEDS; i++)
{
leds[1][i].r = random( 0, 256);
leds[1][i].g = random( 0, 256);
leds[1][i].b = random( 0, 256);
}
break;
}
count++;
if( count > 3)
count = 0;
FastLED.show();
delay(700);
}