Hi all
I'm stuck at a point while using FastLED to animate WS2812B LED light strips, this code is yet incomplete (checking only one array with one button) because I noticed the lights are working even without calling FastLED[0].showLeds(gbrightness) function. My objective is to keep the animation sequence working in IC but show it only when the button is pressed.
Your replies are considered valuable.
Code:
#include "FastLED.h"
#define strip1 48
#define strip2 48
#define strip3 48
#define strip4 48
#define strip5 48
#define FRAMES_PER_SECOND 30
#define DATA_strip1 3
#define DATA_strip2 4
#define DATA_strip3 5
#define DATA_strip4 6
#define DATA_strip5 7
// Define the array of leds
CRGB rpv[strip1];
CRGB sg[strip2];
CRGB first_loop[strip3];
CRGB second_loop[strip4];
CRGB third_loop[strip5];
const int sw1 = 9;
int sw1state;
void setup() {
FastLED.addLeds<WS2812B,DATA_strip1,GRB>(rpv,strip1);
FastLED.addLeds<WS2812B,DATA_strip2,GRB>(sg,strip2);
FastLED.addLeds<WS2812B,DATA_strip3,GRB>(first_loop,strip3);
FastLED.addLeds<WS2812B,DATA_strip4,GRB>(second_loop,strip4);
FastLED.addLeds<WS2812B,DATA_strip5,GRB>(third_loop,strip5);
FastLED.setBrightness(200);
pinMode (sw1,INPUT);
}
//void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
void loop() {
static uint8_t huei = 0;
static uint8_t huej = 24;
uint8_t j=24;
for(int i = 0; i < strip3; i++) {
huei=i;
first_loop[i] = CHSV(huei, 255, 255);
fadeToBlackBy( first_loop, strip3, 150);
FastLED.delay(1000/FRAMES_PER_SECOND);
if (i==strip3) i=0;
if (j==strip3) j=0;
huej=j;
first_loop[j] = CHSV(huej, 255, 255);
j++;
}
sw1state = digitalRead (sw1);
if (sw1state==HIGH)
FastLED[2].showLeds(200);
}
sw1state = digitalRead (sw1);
if (sw1state==HIGH)
FastLED[2].showLeds(200);
i want this part of code to work.