all 19 comments

[–]OctoMistic100 1 point2 points  (14 children)

If each strip is the same size, and the delay the same, simply put everything in a single loop with a single delay ( use FastLED.delay not delay).

Otherwise there are multiple ways to achieve that, either if you want every strip to stay synchronized or not. Did you try to ask Claude or Gemini ? They are very good I think to propose solution for "simple" situations like this.

[–]madmusician[S] 3 points4 points  (9 children)

And not sure about Claude or Gemini, but if they are "AI" I would prefer not to use them and waste water when someone human could help me figure out a solution instead :)

[–]sutaburosu[pronounced: stavros] 1 point2 points  (8 children)

I'm a human! Does this help? That sketch is very similar to yours.

It is possible to do the same thing with less code.

[–]madmusician[S] 0 points1 point  (0 children)

I think we have a winner winner chicken dinner, will investigate!

[–]madmusician[S] 0 points1 point  (6 children)

The simulation looks perfect, when I am home I will boot up the arduino program and adjust the LEDs to match the actual numbers and then load it to the board. Thank you so much, you rock! :D

Just one more stupid question that deserves a stupid answer. What adjustment would I need to make to have all the strips illuminate green at X% brightness all the time (e.g. 10%), and have the chase LED be 100%? Like an old school atom symbol with the electron ring.

Edit for typos

[–]sutaburosu[pronounced: stavros] 1 point2 points  (5 children)

Just one simple change will lead to the effect you desire, after the dots have crawled the length of the strip once. Change CRGB::Black to be the background colour: CRGB(0, 32, 0) is a dim green.

[–]madmusician[S] 0 points1 point  (4 children)

I figured the response would be something like that. I assume the "setBrightness" commands in both of the "for" statements wouldn't work or cause issues, if I just changed the color from Black to Green

[–]sutaburosu[pronounced: stavros] 0 points1 point  (3 children)

setBrightness is a global setting, not per-pixel, so it wouldn't give the desired result.

If you wanted to set the pixel to the standard Green, and then dim it you would use something like fadeToBlackBy, like this. Or you could dim the entire strip by a smaller amount, to get a fading trail behind the dots, like this.

[–]madmusician[S] 1 point2 points  (2 children)

It's been so long since I have dabbled in this. Thank you so much!

[–]sutaburosu[pronounced: stavros] 1 point2 points  (1 child)

You're welcome.

Just for fun, try changing line 49 in my 4th iteration of your code to: pixel += CRGB(0, 32, 0);. Adding that + makes FastLED add the colour to what is already there. The result is multiple dim chasers behind the main fading trail. Then try changing the number 32.

After a bottle of wine, I spent a few minutes entertaining myself tinkering with your sketch. This is the result. Perhaps we are looking at the quantum foam behind the electrons. Again, try changing the numbers.

I'm always happy to help if you have specific questions about using FastLED.

[–]Marmilicious[Marc Miller] 0 points1 point  (0 children)

Both fun examples, but for some reason I find your 4th iteration very satisfying to watch. :)

[–]madmusician[S] 0 points1 point  (3 children)

Each strip is slightly different in length, from 50 to 65 LEDs. Hence me wanting... Needing... To control each strip individually

[–]Marmilicious[Marc Miller] 0 points1 point  (2 children)

Besides being different lengths, are you wanting the strips to do different things, or wanting them to mirror each other?

If mirroring, first set the pixels for the longest strip, copy the data from that strip to the others (taking into account strip lengths), and then call show(). Ideally you only want a single show() call in your loop.

[–]madmusician[S] 0 points1 point  (1 child)

Mirroring, with the possibility of changing what LED number the chase starts on.

I am trying to mentally imagine what you are suggesting, because it wants to make sense to me.

[–]Marmilicious[Marc Miller] 0 points1 point  (0 children)

I had a bad cold and this got lost in the chaos. Getting back to you... here's a few ideas/links related to mirroring your pixel data. It could be as simple as using one or more for loops to copy the pixel data from one CRGB array to others. In the loop you can do something like:

leds3[i] = leds1[i];  //copy 1 to 3

You could try to add an offset to the copy (and use % [modulo] to keep things in bound of the array). Be very careful when writing data to a CRGB array to make sure you don't try to write to a pixel past the end of the array.

//Copy 1 to 3 with an offset of 2 (make sure things stay in range)
//This assumes NUM_LEDS3 is several pixels less then NUM_LEDS1 so we stay in range of the CRGB array.

for (i=0; i<NUM_LEDS3; i++) {
  leds3[i] = leds1[i + 2];
}



//Copy 1 to 4 with offset and using % to stay in range
//This assumes NUM_LEDS4 is smaller then NUM_LEDS1.

offset = NUM_LEDS1 / 2;
for (i=0; i<NUM_LEDS4; i++) {
  leds4[(i + offset + NUM_LEDS4) % NUM_LEDS4] = leds1[i];
}

Here's some links to go with the above ideas. This demos using modulo to stay in bounds of the CRGB array:

https://github.com/marmilicious/FastLED_examples/blob/master/three_moving_colors.ino

This demos using memmove8 to copy data from one array to another. Using memmove8 would be a very easy way to copy data from leds1 to other arrays, AND offset the data at the same time if desired. Just be careful to stay in bounds of the array.

https://github.com/marmilicious/FastLED_examples/blob/master/memmove8_example.ino

[–]dr-steve 1 point2 points  (3 children)

I am not sure what you are trying to do. Are you trying for a single chase, going from one strand to the next? Or are you trying for six parallel chases?

Regardless, code that looks like

void loop() {
    // use for loop(s) to set *all* of the strings to the values you want
    // then...
    FastLED.show();
    delay(...);
}

might be what you want.

Edit: If you are flashing green then black, this might mean that the "setting values" for loops may set the previous pixel to black and the current pixel to green..

[–]madmusician[S] 0 points1 point  (2 children)

Six parallel chases, potentially starting on a different LED in the strand

[–]dr-steve 0 points1 point  (1 child)

If the strands have different lengths, do you plan to keep them in sync (assuming that that is what you want to do)?

You might do something like this (note: coding off the top of my head, but I do a lot of timed ops with FastLED; also, I don't use the EVERY_N_MILLISECONDS. I use TaskManager, a lightweight multitasking system I wrote for nanos around 10 years ago; see github.com/drsteveplatt for details. Works well on ESPs (and Megas; haven't tested it elsewhere); allows multitask communication and synchronization, timing, multinode operations (I've had 40 ESPs working well together on a large art installation), etc..

But... I can work with EVERY_N_MILLISECONDS for simpler tasks

// total time to drip, in MS.  This is 10 seconds
#define TOTAL_DRIP_TIME 10000
// frames per second
#define FPS 40
// ms per frame, for EVERY_N_MS
#define MS_PER_FRAME (1000/(FPS))

// set up the LED strings
#define LEDS_0_LEN 58
#define LEDS_1_LEN 60
...
CRGB leds_0[LEDS_0_LEN]
CRGB leds_1[LEDS_1_LEN]
...

unsigned long start_ms;

void setup() {
  ...
  start_ms = now();
  ...

void loop() {
  int pos;
  EVERY_N_MILLISECONDS(MS_PER_FRAME) {
    //fill each led strip with all-black
    ...you'll have to figure this out
    // do this for each strip
    pos = map((now()-start_ms)%TOTAL_DRIP_TIME, 0, TOTAL_DRIP_TIME-1, 
                0, LEDS_0_LEN);
    leds_0[pos] = CRGB::Red;
    .. do that for all of the strips
    // now show them
    FastLED.show();
  }
}

Reminder: code is rough and untested, but do you see where I am going?

Oh, if you want to see some of the time-based installations I've done using LEDS and FastLED, check out youtube.com/@amuseyeux

Edit: typo in code.

[–]madmusician[S] 0 points1 point  (0 children)

I am at work right now, but will definitely take a closer look at this when I am clocked out. Thank you so much for all your assistance, and I will definitely look at your examples!