Please help with Cyclotron Pattern

Hey, Everyone. I'm working on a Proton Pack project and I've almost got the cyclotron lights how I like them.
I'm working with addressable RGB LEDs. I've got a pattern of four chasing lights, on for one second and fading for one second each. Currently each LED lights up and fades out and then the next one starts, but I'd like the illuminated period to overlap by one second.

Here's my sketch.

#include <FastLED.h>

#define NUM_LEDS 4  // Number of addressable LEDs
#define LED_PIN 6   // Pin connected to the data input of the first LED
#define DELAY_TIME 1000

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
}

void loop() {
  for (int i = 0; i < NUM_LEDS; i++) {
    // Turn on the current LED for one second
    leds[i] = CRGB::Red;
    FastLED.show();
    delay(DELAY_TIME);

    // Fade out the current LED for one second
    for (int brightness = 255; brightness >= 0; brightness--) {
      leds[i].fadeToBlackBy(1);
      leds[i].maximizeBrightness(brightness);
      FastLED.show();
      delay(DELAY_TIME / 255);
    }
  }
}

Here is your current code in simulation.

To make your desired code:

  1. Start a 4 seconds timer.
  2. At seconds 0, start dimming Pix "i" as you did. If pix i dim is less than 0, dim equals 0.
  3. At seconds 1, start dimming Pix "i+1". If pix i+1 dim is less than 0, dim equals 0.
  4. Repeat 3 for i+2 and i+3
  5. When i+3 is at half dim, start pix i.
#include <FastLED.h>

#define NUM_LEDS 4  // Number of addressable LEDs
#define LED_PIN 6   // Pin connected to the data input of the first LED
#define DELAY_TIME 1000

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
}

void loop() {

  static int lastLED = NUM_LEDS - 1;

  for (int i = 0; i < NUM_LEDS; i++) {
    // Turn on the current LED for one second
    leds[i] = CRGB::Red;
    FastLED.show();
    delay(DELAY_TIME);

    // Fade out the current LED for one second
    for (int brightness = 255; brightness >= 0; brightness--) {
      leds[lastLED].fadeToBlackBy(1);
      leds[lastLED].maximizeBrightness(brightness);
      FastLED.show();
      delay(DELAY_TIME / 255);
    }
    lastLED = i;
  }
}

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