Segmen led strip crgbset

hi all, i am new in coding and just begin to learn fastled, hope someone in this forum can
solve my problem. thank you.

Sequence_onepixel_per_segment(); => work fine no problem

Sequence_group_segment(); => sequence do not work. only first pixel light up. how to make sequence work?

wipe(); =>work fine without millis. how to change code into millis?

Thank you


#include <FastLED.h>

#define NUM_LEDS 20
#define Data_Pin 3
#define chipset NEOPIXEL
#define BRIGHTNESS  50
#define group_segment 4
#define led_segment 5
uint8_t x =0;
uint8_t k =0;
uint8_t r=random8(25,225);
uint8_t g=random8(25,225);
uint8_t b=random8(25,225);

// segment

CRGB rawleds[NUM_LEDS];
CRGBSet leds(rawleds, NUM_LEDS);
CRGBSet seg1(leds(0,4));
CRGBSet seg2(leds(5,9));
CRGBSet seg3(leds(10,14));
CRGBSet seg4(leds(15,19));

//group of segment
struct CRGB * group_of_segment[] ={seg1,seg2,seg3,seg4};


//=============================
void setup() { 
 delay(2000); // power-up safety delay 
FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS); 
 FastLED.setBrightness(BRIGHTNESS);
}

//==============================
void loop() { 
  
  //Sequence_onepixel_per_segment();
  //black();
  //Sequence_group_segment();
  //black();
  //wipe();
 // black();

}

//========sequencing one pixel every segment
void Sequence_onepixel_per_segment() 
{ 
   EVERY_N_MILLIS(100)
   { 
      x++; 
      if (x >=led_segment ) {x = 0;}
      //fill_solid(leds,NUM_LEDS, CRGB::Red);
      fadeToBlackBy( leds, NUM_LEDS, 100); 
      seg1[x] =CRGB::Blue ; 
      seg2[x] =CRGB::Magenta ; 
      seg3[x] =CRGB::Blue ; 
      seg4[x] =CRGB::Green ; 
      FastLED.show(); 
   }
} 

//========sequencing group_of_segment
void Sequence_group_segment() 
{
    EVERY_N_MILLIS(100)
    {
      x++; 
      if (x >=group_segment ) {  x = 0;}
      //fill_solid(leds,NUM_LEDS, CRGB::Red);
      fadeToBlackBy( leds, NUM_LEDS, 100); 
      leds[group_of_segment[x][led_segment]]= CRGB::Blue; 
      FastLED.show(); 
    }
} 

//led wipe random color from first to last pixel
void wipe ()
{
 
  /*   //WITHOUT MILLIS
  for (int i = 0; i < NUM_LEDS; i++) 
  {       
       leds[i] = CRGB(r,g,b);   //color work. but not random only one color,  why??
       FastLED.show();
       delay(75);
  }

  for (int i = 0; i < NUM_LEDS; i++) 
  {
       leds[i] = CRGB(r,g,20);
       FastLED.show();
       delay(75);
  }*/

  
   EVERY_N_MILLIS(100)
    {  
     x++; 
      if (x>=NUM_LEDS ) {x=0;
      leds[x] =CRGB::Blue ;}
     // LEDS.show();} 
    
      else if (k>=NUM_LEDS ) {k=0; 
      leds[k] =CRGB(r,g,b) ; x=k;
      }
      
      LEDS.show();}
    //}
       
}

void black(){

fill_solid(leds,NUM_LEDS, CRGB::Black);
LEDS.show();
LEDS.delay(25);
  
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.