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 - Star ...
 
Share:
Notifications
Clear all

[Solved] LED Effects - Star Trek Phaser Array

223 Posts
14 Users
33 Reactions
95.3 K Views
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 

Posted by: @trace

@jackmtaco

You are welcome.

Didn´t have put any other light effects on that code. But that´s my plan. Having some nav lights blinking the whole time and execute different effects by push button.

In what kind of way will you use the PWM module? If you just want some extra PWM outputs on Arduino, you can also use a software PWM, which can make all outputs capable of PWM.

 

It's more so to remotely mount it in the model to minimize running cable runs through the base to the model.


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 

@jackmtaco

Oh, you mean because of SPI connection?


   
jackmtaco reacted
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  
Posted by: @trace

Here are both codes for Warp effect and torpedo effect with sound and pushbutton. Both codes are written for the DFPlayer mini.

Thanks Trace! 😊 👍 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 

@hans

You are welcome.

To combine all 3 effects plus some blinking for navigation lights is harder than expected. Multiple WS2811 strips with different length and one Arduino is a bit more work to do.

Have a nice weekend!


   
ReplyQuote
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 
Posted by: @trace

@hans

You are welcome.

To combine all 3 effects plus some blinking for navigation lights is harder than expected. Multiple WS2811 strips with different length and one Arduino is a bit more work to do.

Have a nice weekend!

Agreed! I was working on the navigational lights coding yesterday and when I put it with the rest of the coding, boom, nothing lol. Trying to troubleshoot it before I ask for help so I can learn what I did wrong. 


   
ReplyQuote
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 

The short edit time allowed on post has me double posting so I apologize. 

I'm not using WS2812 for the nav lights as that just seems like too much with wiring, coding and the size of the LEDs. Instead I'm using standard outputs to control regular LED diodes and also some fiber optics for the smaller areas. 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 
Posted by: @jackmtaco

The short edit time allowed on post has me double posting so I apologize. 

I'm not using WS2812 for the nav lights as that just seems like too much with wiring, coding and the size of the LEDs. Instead I'm using standard outputs to control regular LED diodes and also some fiber optics for the smaller areas. 

This is exactly how Iam doing my lights. If they shall just blink or fade in one color, I use standard LED´s (mostly SMD), often combined with fiber optics. You can take a look at my JJPrise if you want to.

https://www.youtube.com/watch?v=MVrYUOWpW8k

 


   
jackmtaco reacted
ReplyQuote
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 
Posted by: @hans
Posted by: @jackmtaco

That fixed it! Thank you again for your wisdom. 

Awesome! Haha I wouldn't call it wisdom, but I'm happy to see it worked 😁 

Posted by: @jackmtaco

I realized the firing effect for Voyager ship is different from Enterprise (Totally forgot). Instead of a two lights combining to a center point, it's a one way effect to the target LED for Voyager

Just quickly thrown together and untested:

To keep a "generic" function, here a suggestion that may work (note: I've lost track of the latest modifications for this function - so maybe you can post the full code when this works?).
I've added 2 parameters "bidirectional" and "startLeft".

If bidirectional = true then the phaser starts from left and right (the "old" way). The "startLeft" value will be ignored (but needs to be passed as parameter).
If bidirectional = false then the phaser starts either left (startLeft = true) or right (startLeft = false).

This is untested code and I highlighted the changes, which could be useful incase I copied the code of an incorrect version of the startrek_phaser function.
Let me know if it works or not 😊 

void startrek_phaser(byte PhaserRed, byte PhaserGreen, byte PhaserBlue, int TargetLED,
                     byte PhaserWidth, byte ShootingWidth, int msAimDelay, 
                     int PulsateAmount, int msPulsateDelayBright, int msPulsateDelayDarker,
                     bool bidirectional, bool startLeft) 
{
  // These define how much the outer LEDs sim during Aiming, Shooting and Pulsating
  #define DimmingPhaserAim 200
  #define DimmingShoot     128
  #define DimmingPulsing   128
  int PhaserHalf = PhaserWidth/2; // division will take integer part: 3/2 = 1.5 -> 1,  4/2 = 2 -> 2
  int PhaserCenterWidth = 2 - (PhaserWidth%2); // odd numbers: 1, even numbers: 2
  int PhaserAim;
  
  if(TargetLED==-1) 
  {
    PhaserAim = random(NUM_LEDS);     // Pick random aim point
    
    if(PhaserAim < PhaserHalf)         // just making sure we do not go out of the range of LEDs
    {
      PhaserAim = PhaserWidth;
    }
    else if(PhaserAim+PhaserHalf > NUM_LEDS)
    {
      PhaserAim = NUM_LEDS-PhaserHalf;
    }
  }
  else
  {
    PhaserAim = TargetLED;
  }
  
  int StepsLeftside  = PhaserAim;             // 0 - PhaserAim
  int StepsRightside = NUM_LEDS-PhaserAim;    // PhaserAim - NUM_LEDS
  
  int maxSteps = max( StepsLeftside, StepsRightside );
  
  int LEDPos; 
  
  // move LEDs from outside to phaser position
  
  for(int counter=0; counter <= maxSteps; counter++) 
  {
    setAll(0,0,0); // set all LEDs dark

    // Left side towards aim point    
    if( bidirectional || startLeft) // only show the left animation of birectional or startleft
    {
    LEDPos    = PhaserAim-maxSteps+counter;
    
      if( LEDPos >= 0 ) {
        for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++) 
        {
          if(LEDPos+PhaserBlock > 0) 
          {
            leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
            // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
            if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
                  ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
            {
              leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
            }
          } 
        }
      }
    }
    
    // Right side towards aim point
    if( bidirectional || (!startLeft)) // only show right animation if bidirectional or not startleft
    {
      LEDPosLEDPos = PhaserAim+maxSteps-counter;
    
      if( LEDPos < NUM_LEDS ) {
        for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++) 
        {
          if(LEDPos+PhaserBlock < NUM_LEDS) 
          {
            leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
            // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
            if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
                  ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
            {
              leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
            }
          } 
        }
      }
    }
    
    FastLED.show();
    delay(msAimDelay);
  }
// pulsing LEDs when firing phaser LEDPos = PhaserAim; PhaserHalf = ShootingWidth/2; // division will take integer part: 3/2 = 1.5 -> 1, 4/2 = 2 -> 2 PhaserCenterWidth = 2 - (ShootingWidth%2); // odd numbers: 1, even numbers: 2
setAll(0,0,0); // set all to black since shooting width may be different than aiming width
for(int counter=0; counter < PulsateAmount; counter++) { // Set phaser at aim position to the usual brightness for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++) { leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue); // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) { leds[LEDPos+PhaserBlock].fadeLightBy( DimmingShoot ); } }
FastLED.show(); delay(msPulsateDelayBright);
// Make the outer LEDs pulsate (not the center LED or LEDs) for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++) { if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) { leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPulsing ); } }
FastLED.show(); delay(msPulsateDelayDarker); } }

 (I hope the code copied correctly here - the forum seems to like to screw around with the > and < characters if no spaces are placed around them, thinking it may be HTML code)

Happy Monday! So I tried out the latest code and get the error setALL not defined. I fixed one error with missing the define NUM Leds but then the setALL popped up. Any assistance would be great! Thanks! 

 

 

[code]
void startrek_phaser(byte PhaserRed, byte PhaserGreen, byte PhaserBlue, int TargetLED,
byte PhaserWidth, byte ShootingWidth, int msAimDelay,
int PulsateAmount, int msPulsateDelayBright, int msPulsateDelayDarker,
bool bidirectional, bool startLeft)
{
// These define how much the outer LEDs sim during Aiming, Shooting and Pulsating
#define DimmingPhaserAim 200
#define DimmingShoot 128
#define DimmingPulsing 128
#define NUM_LEDS 23
int PhaserHalf = PhaserWidth/2; // division will take integer part: 3/2 = 1.5 -> 1, 4/2 = 2 -> 2
int PhaserCenterWidth = 2 - (PhaserWidth%2); // odd numbers: 1, even numbers: 2
int PhaserAim;

if(TargetLED==-1)
{
PhaserAim = random(NUM_LEDS); // Pick random aim point

if(PhaserAim < PhaserHalf) // just making sure we do not go out of the range of LEDs
{
PhaserAim = PhaserWidth;
}
else if(PhaserAim+PhaserHalf > NUM_LEDS)
{
PhaserAim = NUM_LEDS-PhaserHalf;
}
}
else
{
PhaserAim = TargetLED;
}

int StepsLeftside = PhaserAim; // 0 - PhaserAim
int StepsRightside = NUM_LEDS-PhaserAim; // PhaserAim - NUM_LEDS

int maxSteps = max( StepsLeftside, StepsRightside );

int LEDPos;

// move LEDs from outside to phaser position

for(int counter=0; counter <= maxSteps; counter++)
{
setAll(0,0,0); // set all LEDs dark

// Left side towards aim point
if( bidirectional || startLeft) // only show the left animation of birectional or startleft
{
LEDPos = PhaserAim-maxSteps+counter;

if( LEDPos >= 0 ) {
for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++)
{
if(LEDPos+PhaserBlock > 0)
{
leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
// only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) ||
( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) )
{
leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
}
}
}
}
}

// Right side towards aim point
if( bidirectional || (!startLeft)) // only show right animation if bidirectional or not startleft
{
LEDPosLEDPos = PhaserAim+maxSteps-counter;

if( LEDPos < NUM_LEDS ) {
for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++)
{
if(LEDPos+PhaserBlock < NUM_LEDS)
{
leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
// only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) ||
( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) )
{
leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
}
}
}
}
}

FastLED.show();
delay(msAimDelay);
}

// pulsing LEDs when firing phaser
LEDPos = PhaserAim;
PhaserHalf = ShootingWidth/2; // division will take integer part: 3/2 = 1.5 -> 1, 4/2 = 2 -> 2
PhaserCenterWidth = 2 - (ShootingWidth%2); // odd numbers: 1, even numbers: 2

setAll(0,0,0); // set all to black since shooting width may be different than aiming width

for(int counter=0; counter < PulsateAmount; counter++) {
// Set phaser at aim position to the usual brightness
for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++)
{
leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
// only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) ||
( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) )
{
leds[LEDPos+PhaserBlock].fadeLightBy( DimmingShoot );
}
}

FastLED.show();
delay(msPulsateDelayBright);

// Make the outer LEDs pulsate (not the center LED or LEDs)
for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++)
{
if ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) ||
( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) )
{
leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPulsing );
}
}

FastLED.show();
delay(msPulsateDelayDarker);
}
}
[/code]

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  
Posted by: @jackmtaco

get the error setALL not defined

This usually points to either a chunk of code missing, or accolades being "out of sync" (eg. there is a "{" somewhere, but it is missing it's counterpart "}").

Since you were missing NUM_LEDS, I presume you're missing a lot more of the other code as well, since NUM_LEDS is defined in the beginning.
Maybe you pasted this all as if it was one sketch? The function was intended as an addition to an existing sketch 😊 
Eg. you're may be missing the context code. My bad if that wasn't clear.

Took me a bit to find the original stuff, all the way back to January 14th of this year it seems haha.

So ... the full code could be (sketch file added):

 

The code:

 

#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
#define PIN 6

void setup()
{
  FastLED.addLeds< WS2811, PIN, GRB >(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  randomSeed(analogRead(0)); // for a better random
}

void loop() 
{
  startrek_phaser( 0xff, 0x90, 0, -1, 4, 4, 10, 20, 60, 40, false, true); // TargetLED = -1 = random pick
  delay(1000); // delay between phase shots
}

void startrek_phaser(byte PhaserRed, byte PhaserGreen, byte PhaserBlue, int TargetLED,
                     byte PhaserWidth, byte ShootingWidth, int msAimDelay, 
                     int PulsateAmount, int msPulsateDelayBright, int msPulsateDelayDarker,
                     bool bidirectional, bool startLeft) 
{
  // These define how much the outer LEDs sim during Aiming, Shooting and Pulsating
  #define DimmingPhaserAim 200
  #define DimmingShoot     128
  #define DimmingPulsing   128

  int PhaserHalf = PhaserWidth/2; // division will take integer part: 3/2 = 1.5 -> 1,  4/2 = 2 -> 2
  int PhaserCenterWidth = 2 - (PhaserWidth%2); // odd numbers: 1, even numbers: 2

  int PhaserAim;
  
  if(TargetLED==-1) 
  {
    PhaserAim = random(NUM_LEDS);     // Pick random aim point
    
    if(PhaserAim < PhaserHalf)         // just making sure we do not go out of the range of LEDs
    {
      PhaserAim = PhaserWidth;
    }
    else if(PhaserAim+PhaserHalf > NUM_LEDS)
    {
      PhaserAim = NUM_LEDS-PhaserHalf;
    }
  }
  else
  {
    PhaserAim = TargetLED;
  }
  
  int StepsLeftside  = PhaserAim;             // 0 - PhaserAim
  int StepsRightside = NUM_LEDS-PhaserAim;    // PhaserAim - NUM_LEDS
  
  int maxSteps = max( StepsLeftside, StepsRightside );
  
  int LEDPos; 
  
  // move LEDs from outside to phaser position
  
  for(int counter=0; counter <= maxSteps; counter++) 
  {
    setAll(0,0,0); // set all LEDs dark

    // Left side towards aim point
    
    if( bidirectional || startLeft) // only show the left animation of birectional or startleft
    {
      LEDPos    = PhaserAim-maxSteps+counter;
    
      if( LEDPos >= 0 ) {
        for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++) 
        {
          if(LEDPos+PhaserBlock > 0) 
          {
            leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
  
            // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
            if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
                  ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
            {
              leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
            }
          } 
        }
      }
    }

    // Right side towards aim point

    LEDPos = PhaserAim+maxSteps-counter;
    
    if( bidirectional || (!startLeft)) // only show right animation if bidirectional or not startleft
    {
      if( LEDPos < NUM_LEDS ) {
      
        for (int PhaserBlock = 0; PhaserBlock < PhaserWidth; PhaserBlock++) 
        {
          if(LEDPos+PhaserBlock < NUM_LEDS) 
          {
            leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);
  
            // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
            if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
                  ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
            {
              leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPhaserAim );
            }
          } 
        }
      }
    }
    
    FastLED.show();
    delay(msAimDelay);
    delay(100);
  }

  // pulsing LEDs when firing phaser

  LEDPos     = PhaserAim;
  PhaserHalf = ShootingWidth/2; // division will take integer part: 3/2 = 1.5 -> 1,  4/2 = 2 -> 2
  PhaserCenterWidth = 2 - (ShootingWidth%2); // odd numbers: 1, even numbers: 2

  setAll(0,0,0); // set all to black since shooting width may be different than aiming width

  for(int counter=0; counter < PulsateAmount; counter++) {

    // Set phaser at aim position to the usual brightness
    for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++) 
    {
      leds[LEDPos+PhaserBlock] = CRGB( PhaserRed, PhaserGreen, PhaserBlue);

      // only center (odd width) or center 2 LEDs (even width) should be bright, others need to fade
      if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
            ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
      {
        leds[LEDPos+PhaserBlock].fadeLightBy( DimmingShoot );
      }
    }
    FastLED.show();
    delay(msPulsateDelayBright);

    // Make the outer LEDs pulsate (not the center LED or LEDs)
    for (int PhaserBlock = 0; PhaserBlock < ShootingWidth; PhaserBlock++) 
    {
      if  ( ( (PhaserCenterWidth==1) && (PhaserBlock!=PhaserHalf) ) || 
            ( (PhaserCenterWidth==2) && (PhaserBlock!=PhaserHalf-1) && (PhaserBlock!=PhaserHalf) ) ) 
      {
        leds[LEDPos+PhaserBlock].fadeLightBy( DimmingPulsing );
      }
    }
    FastLED.show();
    delay(msPulsateDelayDarker);
    
  }
}

// Set all LEDs to a given color and apply it (visible)
void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    leds[i] = CRGB(red, green, blue);
  }
  
  FastLED.show();
}

I hope this pasted correctly, since the forum keeps seeing "<" as the beginning of HTML code and then removes/changes it, unless it is followed by a space (which would break for example and #include statement). So I've attached the sketch additionally.


   
jackmtaco reacted
ReplyQuote
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 

That was my fault as I thought it was a full sketch. I will give it a try here shortly. Thanks again and I will report back soon. 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

No problem  😉 
Also a good learning moment for all of us 😁 

I just tested this code on my Arduino, so it should work 😊 


   
jackmtaco reacted
ReplyQuote
(@jackmtaco)
Eminent Member
Joined: 4 years ago
Posts: 22
 

So that works but the effect is really slow, where do I control the speed of the light chase to it's target? I'm also having issues with changing the width of it. I don't understand the comment that says 3/2 = 1.5. Can you help clarify what that means?

Edit, Figured out the speed of the light chasing. Just trying to figure out the width of the phaser. 


   
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 
Posted by: @jackmtaco

So that works but the effect is really slow, where do I control the speed of the light chase to it's target? I'm also having issues with changing the width of it. I don't understand the comment that says 3/2 = 1.5. Can you help clarify what that means?

Edit, Figured out the speed of the light chasing. Just trying to figure out the width of the phaser. 

You can change a lot of the effect with changing the "byte". On page 1 you can find a post from Hans where he has written down all bytes, what they mean and what change will do what.

If you want to change the width of the phaser, you can change "byte PhaserWidth" which is the amount of LED´s running down to the aim point. If you want to change the width of the shooting effect then change "byte ShootingWidth"

As you can see in the code, the loop contains the parameters and "void strartrek_phaser" contains the corresponding definitions (I have colorised it).

void loop() 
{
  startrek_phaser( 0xff, 0x90, 0, -1, 4, 4, 10, 20, 60, 40); // TargetLED = -1 = random pick
  delay(1000); // delay between phase shots
}
void startrek_phaser(byte PhaserRed, byte PhaserGreen, byte PhaserBlue, int TargetLED,
                     byte PhaserWidth, byte ShootingWidth, int msAimDelay, 
                   int PulsateAmount, int msPulsateDelayBright, int msPulsateDelayDarker)

 

Here is the list of parameters:

PhaserRed, PhaserGreen, PhaserBlue: define the color of the LEDs (0xff, 0x90, 0 = orange).

TargetLED: The LED at what position needs to be "fired" (use "-1" for a random position).

 

PhaserWidth: the number of LEDs used to "walk" to the aiming position. 4 seemed nice.

ShootingWidth: the number of LEDs used when "firing" and here 3 or 4 seems nice.

msAimDelay: the milliseconds delay between each step when "walking" to the firing position (less = faster), 10 seemed good here.

 

PulsateAmount: how many times the phaser needs to pulse when firing - I picked 20.

msPulsateDelayBright: the milliseconds delay while "firing" before going to a darker color (less = shorter), 60 seemed good.

msPulsateDelayDarker: the milliseconds delay while "firing" before going to a brighter color (less = shorter), 40 seemed good.

 

Since you may want to tweak this as well, I've defined 3 values (didn't want to add even more parameters to the function);

 

DimmingPhaserAim: the amount the outer LEDs will dim while aiming

DimmingShoot: the amount the outer LEDs will dim when firing

DimmingPulsing: the amount the outer LEDs will dim when pulsating while firing.

 

Note: When the phaser is made of an odd number of LEDs (for example "3"), then the middle LED will be the bright one.

When the phaser is made of an even number of LEDs (>3) then the middle 2 LEDs will be bright.


   
jackmtaco reacted
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 

@jackmtaco Didn´t hit reply, so I hope you will see my post although.


   
jackmtaco reacted
ReplyQuote
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 

@hans

I´m totally busy again but I still try to figure out stuff by my own. Got stuck with combining all effects. Because this will mean, I have to use multiple WS2811 strips with different amount of LED´s with one Arduino.

It seems I have to use multiple controllers right? And I understand the fastled example of it. But the example is for multiple LED strips with the same amount of LED´s and it is a completely different story to make it work with all 3 effects within one code (Phaser, Warp, Torpedo). For the Phase I will have about 60 LEDs, for the Warp about 16 each side (would just split data pin) and just one or two LEDs for the Torpedo effect.

Im glad it will be the same kind of LED strip and not also different types :D

So maybe you could give a hint how to combine all this. (Later I will try to implement some standard LEDs which shall just blink with different timings. I would use an array for it and millis. Hopefully this will work and doesn´t get interrupted by triggering one of our effects).


   
ReplyQuote
Page 10 / 15
Share: