Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



LED Effects - Combi...
 
Share:
Notifications
Clear all

[Solved] LED Effects - Combine Theater Chase and Strobe (FastLed)

4 Posts
2 Users
0 Reactions
1,293 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Hi all, I'm french, so sorry if my English is not very understandable.

I already seen this forum for a little projet few years ago.

I have a new project and for it, I need to combine the theater Chase and strobe effect.

For more details, I use FastLed with an Arduino Uno and strip Led WS2811 (300 pixels).

Currently I succeed to make the theater chase with 2 colors White/red (but I have a problem and I don't know why, the first 4 pixel stay in white) in this effect I would like to make a stroboscopic effect in the same time too.

My theater chase need to blink (the blink frequence must be variable with a static value example : "int FlashDelay" of the origine strobe effect).

One of you already make this or can help me to make this ?

1 - The first 4 pixels stayed white I don't know why.

2 - I would like to blink all led in the same times of the theater chase

You understand what I want ?

Link to video : https://youtube.com/shorts/Npiw4dE6q1E?feature=share

 

Thanks all 😁

PS : I'm not an expert with C Langage, a learn myself.

PS 2 : I use a lot of WS2811 pixels for made light show with Falcon Pi Player and Xlight.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

Well, it looks you're the first one (here) that is thinking of this effect - cool though, we like new effects 😁 
And ... nothing wrong with your English - wait until you hear my French haha 😊 

Just for reference I've placed the existing code for TheaterChase and Strobe, so we do not need to jump back and forth between this topic and the original LED Effects article.

void loop() {
  theaterChase(0xff,0,0,50);
}

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, red, green, blue);    //turn every third pixel on
      }
      showStrip();
     
      delay(SpeedDelay);
     
      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, 0,0,0);        //turn every third pixel off
      }
    }
  }
}

 

void loop() {
  // Slower:
  // Strobe(0xff, 0x77, 0x00, 10, 100, 1000);
  // Fast:
  Strobe(0xff, 0xff, 0xff, 10, 50, 1000);
}

void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
  for(int j = 0; j < StrobeCount; j++) {
    setAll(red,green,blue);
    showStrip();
    delay(FlashDelay);
    setAll(0,0,0);
    showStrip();
    delay(FlashDelay);
  }
 
 delay(EndPause);
}

 

I have to admit that I'm still not quite sure what you are thinking off, so correct me if I'm wrong:

1) The theaterchase effect runs (as in the video)
2) At certain moments the entire strips flashes on/off white light, and then continues the theaterchase.

Is that correct?

If so then I can see a few ways to accomplish that - I do not have any hardware handy at the moment, so all of this is untested.

You could try it by modifying the existing theaterchase function, where it calls the strobe effect. However, the theaterchase relies on your not modifying the LED colors, which the strobe effect would. So we'd need to make a backup of the LED array, do the strobe effect, and then restore the backup.

A very fast way to make a backup would be with memcpy, which copies a chunk of memory.
We'd need a second CRGB array for that.

memcpy(leds, leds_backup, NUM_LEDS*3);

So this copies a chunk of memory, starting a the start address in memory of the "leds" array.
The amount of data that is being copied = number of leds x the 3 color values (RGB).
And we copy that to the begin address of the leds_backup variable - overwriting whatever is in it.

After showing the strobe we'd of course need to restore the colors, and we do this the same way.

So code could look something like this (assuming I understood the desired LED effect).

Note: untested, I do not have the needed hardware handy.
The new part in the theaterchase function is clearly marked with the asterisks 😊 

...
CRGB leds[NUM_LEDS];        // the normal LED array
CRGB leds_backup[NUM_LEDS]; // LED color array for making a backup
...

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, red, green, blue);    //turn every third pixel on
      }
      showStrip();
     
      delay(SpeedDelay);

  // ************************

      // make a backup of the current LED colors
      memcpy(leds, leds_backup, NUM_LEDS*3);   

      // call strobe function - fine tine as needed of course
      Strobe(0xff, 0xff, 0xff, 10, 50, 1000);

      // restore backup the old LED colors
      memcpy(leds_backup, leds, NUM_LEDS*3);

      // make the restored colors visible
      showStrip;
     
  // ************************

      for (int i=0; i < NUM_LEDS; i=i+3) {
        setPixel(i+q, 0,0,0);        //turn every third pixel off
      }
    }
  }
}

 

So before going in deeper I'd probably need to understand better what the desired effect is.

Hope this helps ... 😁 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
 

Forgot to answer your other question "The first 4 pixels stayed white I don't know why".
For that I'd need the code of the function you're using.
Since it's the first for LEDs, maybe somewhere in the code you started counting at "1" instead of "0".
Arrays items are counted 0 to the number or elements minus 1.

So 300 LEDs count from 0 - 299.
However, if counting starts at (eg. 1-299) then the first one is skipped, and since the chase works with "blocks", it potentially skips the first "block" (eg. first 4 LEDs).


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Hi Hans, 

very good, if my english is understandable, maybe your french is more better that you think 😂

Thanks for your reply and your "code", but sorry to say that he doesn't work, this juste make a strobe effect.

Below my currently code : 

 

void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 10; q++) {
      for (int i=0; i < NUM_LEDS; i=i+5) {
        setPixel(i+q, red, green, blue);    //turn every third pixel on
      }
      showStrip();
     
      delay(SpeedDelay);
      
      for (int i=0; i < NUM_LEDS; i=i+10) {
        setPixel(i+q, 255,255,255);        //turn every third pixel off
      }

      delay(SpeedDelay);
     
    }
  }
}

 

I would like 5 pixels in red and 5 pixels in white and all move like the theatre chase, I think one parameters is wrong.

 

For the strobe effect all led must off and on.. like you switch on/switch off but the theatre chase don't restart just continue.

You understand betteror it's always blurry 😂

 

 


   
ReplyQuote
Share: