2 row 2 strip slow fill/swipe and hold help

I am looking for example code or guidance on what or how to code for my animation.

I have a project to create an animation behind a hole pattern that looks flows from front to rear with the first and/or second LED to lead a fill pattern that is 50% brightness as the first.

I have 2 rows, 18 WS2112B LEDs each (2 separate strips with 2 different pins) that I want to control.
I tried to use TinkerCad, WOKWI and others but still cannot get what I am looking for. I can get a comet, comet wipe, theater chase but do not know how to get what I am looking for.

I want the starting LED(s) to lead a swipe that holds the LEDs at 50% brightness when the starting LEDs goto the end of the strips.

I would also like to have another animation with the animation flowing from the bottom right LED to the top left LED.

I can share a video of the animation(s) that I am looking to achieve.
I am not looking for someone to write the code but to share any similar animations. I am new to Arduino coding and have only tested the example libraries of FastLED, FadeLED, Adafruit and NeoPixel.

Any help is greatly appreciated.

Need to post up some wiring diagrams and code you’ve tried

There are several patterns requested but I feel if I get one pattern working I can tinker with the others as I learn.
For proof of concept I am using 2 rows of WS2812B and want to flow from right to left. also I would like to be able to turn the bottom row on 100% brightness, then go 50% while the top row goes 100% to have a bottom to top wave.

I am hoping for a white flow, starting 100% brightness and trailing 50% and held when fill is complete.

The final mock up will be similar to image of the PCB with numbered LEDs shown. So the lighting flow would go from right to left with a bright wave front and the trailing LEDs to be 50% brightness and stay on when the 1st LEDs go away.


DOOR_DECO_LIT_MOCK_UP_2_led_strip_051221.ino (7.6 KB)

#include "FastLED.h"   //Make sure to install the FastLED library into your Arduino IDE

//The total number of LEDs being used is 144
#define NUM_LEDS 18

// The data pin for the NeoPixel strip is connected to digital Pin 6 on the Arduino
#define DATA_PIN 6
#define DATA_PIN_a 8

// The button will be connected to digital pin 9 on the Arduino. Uses Internal pullup resistor.
#define BUTTON 9

//Initialise the LED array, the LED Hue (ledh) array, and the LED Brightness (ledb) array.
CRGB leds[NUM_LEDS];
byte ledh[NUM_LEDS];
byte ledb[NUM_LEDS];

const int LEDSpeed = 1; //Speed of the LED animation effect. Make sure not to exceed the maxLEDSpeed value.
int maxLEDSpeed = 100;    //Identifies the maximum speed of the LED animation sequence
int LEDposition=0;       //Identifies the LED position in the strip that the comet is currently at. The maximum position is NUM_LEDS-1  (eg. 143)
int oldPosition=1;       //Holds the previous position of the comet.

byte hue = 0;            //Stores the Leading LED's hue value (colour)
byte sat = 255;          //Stores the Leading LED's saturation value
byte tailHue = 0;        //Stores the Comet tail hue value
int tailLength = 1;      //determines the length of the tail.
byte hueRange = 0;      //Colour variation of the tail (greater values have greater variation
byte intensity = 255;    //The default brightness of the leading LED
byte tailbrightness= intensity / 3;  //Affects the brightness and length of the tail
int animationDelay = 10;  //The greater the animation delay, the slower the LED sequence. Calculated from LEDSpeed and MaxSpeed.

unsigned long waitTime = 500;  //The wait time for each comet is currently set for 1 minute (or 60000 milliseconds).
unsigned long endTime;   //The time when we no longer have to wait for the next comet

int cometNumber = 1;     //Used to choose which comet colour to show (***Don't change this variable***)


//===================================================================================================================================================
// setup() : Is used to initialise the LED strip
//===================================================================================================================================================
void setup() {
    delay(1000);          //Delay for two seconds to power the LEDS before starting the data signal on the Arduino
    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);                            //initialise the LED strip 
    FastLED.addLeds<WS2812B, DATA_PIN_a, GRB>(leds, NUM_LEDS);    
    
    pinMode(BUTTON, INPUT_PULLUP);                                                      //Connect button to digital pin 9, and use the internal pullup resistor
    selectNextComet();                                                                  //Select the next comet colour
}


//===================================================================================================================================================
// loop() : 
//===================================================================================================================================================
void loop(){
    showLED(LEDposition, hue, sat, intensity);

    //Adjust the hue of the tail so that it is a different colour from the leading LED. To reduce variation in tail colour, reduce the hueRange.
    if(hue>(254-hueRange)){
      tailHue = random((hue-hueRange),hue);
    } else {
      tailHue = random(hue, (hue+hueRange)); 
    }
    
   //tailbrightness = random(50);                      //Randomly select the brightness of the trailing LED (provides sparkling tail)

    
    leds[LEDposition]=CHSV((tailHue),sat,tailbrightness);  //Set the colour, saturation and brightness of the trailing LED
    fadeLEDs(tailLength);                                  //Fade the tail so that the tail brightness dwindles down to nothingness.
    setDelay(LEDSpeed);                                    //

    LEDposition++;
    if(LEDposition>(NUM_LEDS-0)){
      
      for(int i=0; i<50; i++){
        showLED(LEDposition, hue, sat, intensity);
        fadeLEDs(tailLength);
        setDelay(LEDSpeed);
      } 
      LEDposition=0;
      selectNextComet();                                  //Select the next comet colour
//      waitForNextComet();                                 //wait for the next comet (either 60 seconds or button press)
    }
  
}


//===================================================================================================================================================
// showLED() : is used to illuminate the LEDs 
//===================================================================================================================================================
void showLED(int pos, byte LEDhue, byte LEDsat, byte LEDbright){
  leds[pos] = CHSV(LEDhue,LEDsat,LEDbright);
  FastLED.show();
}


//===================================================================================================================================================
// fadeLEDs(): This function is used to fade the LEDs back to black (OFF) 
//===================================================================================================================================================
void fadeLEDs(int fadeVal){
  for (int i = 0; i<NUM_LEDS; i++){
    leds[i].fadeToBlackBy( fadeVal );
  }
}


//===================================================================================================================================================
// setDelay() : is where the speed of the LED animation sequence is controlled. The speed of the animation is controlled by the LEDSpeed variable.
//              and cannot go faster than the maxLEDSpeed variable.
//===================================================================================================================================================
void setDelay(int LSpeed){
  animationDelay = maxLEDSpeed - abs(LSpeed);
  delay(animationDelay);
}


//===================================================================================================================================================
//selectNextComet() : This is where we select either the Blue, the Pink or the White comet         
//===================================================================================================================================================
void selectNextComet(){
  cometNumber++;
  if(cometNumber>3){
    cometNumber=1;
  }

  switch(cometNumber){
    case 1:  {    //Blue Comet
      hue = 0;
      sat = 0;
      hueRange=0;
      break;
    }
 
    case 2:  {   //Pink Comet
      hue = 224;
      sat = 120;
      hueRange=10;
      break;
    }
    
    default: {   //White Comet
      hue = 0;
      sat = 0;
      hueRange = 0;
      break;
    }  
  }
}


//===================================================================================================================================================
// waitForNextComet() : Is where we either wait for 60 seconds for another comet to come, or initiate another comet with a button press.
//                      The button will only be "ACTIVE" while we are waiting for the next comet. It has no effect while a comet is currently running         
//===================================================================================================================================================
void waitForNextComet(){
    endTime = millis() + waitTime;

    while(millis()<endTime){
      if(digitalRead(BUTTON)==LOW){
         break;
      }
    }
}```

I created new code (removed what I found to be unnecessary).
I am hoping to understand what function(s) determine;
color, intensity, speed and LED positions and how to reverse the directions.

I am using an Arduino Mega 2560
Pins 6 and 8 for LED strips
5V power and ground

I would like to have the first 2 LEDs in the first column to illuminate with the others trailing behind at 50% brightness and staying when they are all filled.

Then to have a break that turns the LEDs black then to start another loop.
I would like to use CRGB color coding instead of the CVSR (it seems too complicated to come up with a color of choice).

There is some detail in the code of other flows that I am trying to create and hopefully by learning the items mentioned above I can come up with additional code.

#include "FastLED.h"   //Make sure to install the FastLED library into your Arduino IDE

//The total number of LEDs being used is 36
#define NUM_LEDS 18

// The data pin for the NeoPixel strip is connected to digital Pin 6 on the Arduino
#define TOP_ROW 6
#define BOTTOM_ROW 8


//Initialise the LED array, the LED Hue (ledh) array, and the LED Brightness (ledb) array.
CRGB leds[NUM_LEDS];
byte ledh[NUM_LEDS];
byte ledb[NUM_LEDS];

const int LEDSpeed = 10; //Speed of the LED animation effect. Make sure not to exceed the maxLEDSpeed value.
int maxLEDSpeed = 200;    //Identifies the maximum speed of the LED animation sequence
int LEDposition = 0;     //Identifies the LED position in the strip that the comet is currently at. The maximum position is NUM_LEDS-1  (eg. 143)
int oldPosition = 0;     //Holds the previous position of the comet.

byte hue = 100;            //Stores the Leading LED's hue value (colour)
byte sat = 25;          //Stores the Leading LED's saturation value
byte tailHue = 0;        //Stores the Comet tail hue value

byte hueRange = 0;      //Colour variation of the tail (greater values have greater variation)
byte intensity = 150;    //The default brightness of the leading LED
byte tailbrightness = intensity / 2; //Affects the brightness "/2 means 50%"
int animationDelay = 50;  //The greater the animation delay, the slower the LED sequence. Calculated from LEDSpeed and MaxSpeed.


int flow = 1;     //Used to choose which flow to show (***Don't change this variable***)


//===================================================================================================================================================
// setup() : Is used to initialise the LED strip
//===================================================================================================================================================

void setup() {
  delay(1000);          //Delay for two seconds to power the LEDS before starting the data signal on the Arduino
  FastLED.addLeds<WS2812B, TOP_ROW, GRB>(leds, NUM_LEDS);    //initialise the LED strip
  FastLED.addLeds<WS2812B, BOTTOM_ROW, GRB>(leds, NUM_LEDS);

  selectFlow();             //Select the next flow front
}


//===================================================================================================================================================
// loop() :
//===================================================================================================================================================
void loop() {
  showLED(LEDposition, hue, sat, intensity);

  //Adjust the hue of the tail so that it is a different colour from the leading LED. To reduce variation in tail colour, reduce the hueRange.
  if (hue > (0 - hueRange)) {
    tailHue = ((hue - hueRange), hue);
  }

  leds[LEDposition] = CHSV((tailHue), sat, tailbrightness); //Set the colour, saturation and brightness of the trailing LED
  setDelay(LEDSpeed);

  LEDposition++;
  if (LEDposition > (NUM_LEDS )) {

    for (int i = 0; i < 50; i++) {
      showLED(LEDposition, hue, sat, intensity);
      setDelay(LEDSpeed);
    }
    LEDposition = 0;
  }
}


//===================================================================================================================================================
// showLED() : is used to illuminate the LEDs
//===================================================================================================================================================
void showLED(int pos, byte LEDhue, byte LEDsat, byte LEDbright) {
  leds[pos] = CHSV(LEDhue, LEDsat, LEDbright);
  FastLED.show();
}

//===================================================================================================================================================
// setDelay() : is where the speed of the LED animation sequence is controlled. The speed of the animation is controlled by the LEDSpeed variable.
//              and cannot go faster than the maxLEDSpeed variable.
//===================================================================================================================================================

void setDelay(int LSpeed) {
  animationDelay = maxLEDSpeed - abs(LSpeed);
  delay(animationDelay);
}
//===================================================================================================================================================
//  flow1  =  (100% right to left 1st 2 LEDs then w/50% solid fill to follow and hold)
//  flow2  =  (100% left to right 1st 2 LEDs then w/50% solid fill to follow and hold)
//  flow3  =  (100% bottom row w/50% top row -->> 50% bottom row w/100% top row -->> 100% bottom row w/50% top row)
//  flow4  =  (start at bottom right to top left to look like a roman candle)
//====================================================================================

void selectFlow() {
  flow++;
  if (flow = 1) {
    flow = 1;
  }

  switch (flow) {
    case 1:  {   // white flow
        hue = 100;
        sat = 20;
        hueRange = 0;
        break;
     }
  }
}


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