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
83.3 K Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2708
Topic starter  

You're welcome! 😊 

Oh, now there is a good use of something I never use - excellent idea! 👍 
They shouldn't be too expensive either. I'll have to see if I can find one. 


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

@hans

If we'd want to make it fit an exact time, then I'm afraid we'd still be hoping for the best timing, since speed can be different per LED strip, and per Arduino (although we'd be able to get pretty close). It would also have implications with the code, so for now we're stuck with trial and error.

Oh I love that Klingon effect - wow, really nice, especially with the frosted material in front of it. Nice!!

And Im sure it would be tricky to get exact timings and a nice fade from/to color effect in coding. And because it is just a model which doesn´t need exact timings, I will stick with trial and error.

 

 

@jackmtaco

You could also use a vapor smoking device with a little airpump. There are a lot of "how to" videos on youtube. And be careful with Laser, often they are more powerful than they should be and it is still dangerous if someone is looking at your model and accidentally looks straight into the laser.

Will you try to make the warp nacelles move? I was planning that too but don´t got time to do that...like so many other projects.

I will upload the code including sound and button for warp later this week. If I got time I will try to combine all effects in one code.


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

 

@jackmtaco

You could also use a vapor smoking device with a little airpump. There are a lot of "how to" videos on youtube. And be careful with Laser, often they are more powerful than they should be and it is still dangerous if someone is looking at your model and accidentally looks straight into the laser.

Will you try to make the warp nacelles move? I was planning that too but don´t got time to do that...like so many other projects.

I will upload the code including sound and button for warp later this week. If I got time I will try to combine all effects in one code.

I have a little fan that is quiet that I plan to force air through a little tubing in front of the model to create the effect. In regards to the warp nacelles. I've thought about ways to do it and have seen some peoples setups with them but the problem is they are so loud! (the servo motors they use) Takes away from the actual effect of the nacelles moving up and down. I've been drumming up ides with how I want to do it with either a stepper motor and spring loading the pivoting points so that the noise will be reduced greatly or by using a solenoid and varying the amount of power that goes to it to slowly pull on a wire through pullies to pull them up and then have them under spring tension to slowly lower them (Kind of like a garage door opening type setup, placing the motor/solenoid inside the saucer front section so there's more room to work with) Still working on the details on that one but will keep you guys updated on what I do. Don't want to give away all my secrets just yet!!!! lol 

At least on the Enterprise models (I have all of them sitting in kits in a closet I have yet to complete!! =( ) there is a lot more room! The back end of Voyager's haul at the nacelles lacks a lot of space to work with unfortunately so there's a lot of (excuse the pun) engineering to be done in the engineer section to make it work the way I envision it. 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2708
Topic starter  
Posted by: @trace

And be careful with Laser, often they are more powerful than they should be and it is still dangerous if someone is looking at your model and accidentally looks straight into the laser.

You're very correct about that, but since Jack wants to point it in one direction, I'm sure he will not be pointing at peoples eyes. Also something to play with when it comes to lasers: experiment with the used Voltage. You could tune them to the bare minimum to make them less dangerous (still not safe to look into of course).

Posted by: @trace

Will you try to make the warp nacelles move

Would it be an idea to make the nacelles appear to be moving? One could use LEDs maybe for that?


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

As I'm in no way experienced with building these cool Star Trek models, I was just wondering of you guys have seen this YouTube video? (it helped me looking at what the nacelle "motion" would look like)


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

@hans

Hope your day is going well! I loaded up the code for just the phaser effect and it's working great! I just had a question regarding specifying the aiming again. Do the LED's follow a specific address or is it just 1, 2, 3, 4.... If I change the TargetID from -1 to any number, the leds just aims at the first 4 leds in the strip. Thanks for the help! 


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

@jackmtaco

Thanks Jack! I'm doing well, hope you're doing well too! 😊 

From what I could find in the conversation with Trace (feel free to post the full code if you have it - probably best as an attachment);

This section (below) looks if TargetLED is = -1, if so: random position (PhaserAim).
If not -1 then use the defined LED position.

LEDs are numbered 0 - X  (where X = NUM_LEDS -1).

So if you have 60 LEDs, then "29" should be the middle (kind-a, since there is no middle with an even number of LEDs).
You may want to play with the PhaserWidth and ShootingWidth values as well.

If this doesn't work as expected, then I'll have to look at the complete sketch to see what may be going wrong.

 

  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;
  }

 


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

@hans

Thanks for the quick response, I'm getting ready to try it out again. Will let you know the results. 


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

That fixed it! Thank you again for your wisdom. 

I have an idea I would like to propose but first I'm gonna try the rest of the coding scripts you provided in here and figure out how to use my music maker shield for the sound. The good thing is, it has a separate set of GPIO pins for activating script functions but I will need to get everything hooked up and tested for that.

https://youtu.be/kwMRZ4tCJHQ


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

Okay so after rewatching a few voyager episodes, 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. What would I need to modify code wise to make that happen? I may also end up putting a servo on the laser diode to move it around as that is the effect what really happens in the series. I've posted a youtube video below to better demonstrate the effect. 

 

https://youtu.be/EYXcfzJWfjA?t=29

 

 

https://youtu.be/bzHxgX7n4lo?t=40


   
Hans reacted
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2708
Topic starter  
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)


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

Hello everyone (well Hans and jackmtaco).

Here are both codes for Warp effect and torpedo effect with sound and pushbutton. Both codes are written for the DFPlayer mini. Don´t know anything about the Arduino sound shield. But im curious to see what jackmtaco is able to do with it.

Timings are for my specific sound effects, so maybe they need adjustments if using your own sounds. Also in the code I have a sound command for the push button.


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

For the moving Voyager Warp nacelles. They literally do move for warp. From a horizontal to a 30 degree angle. What you, Hans, mean is the bussard collector effect. Here it is a rotating "grill" with flashing, fading and blinking lights behind a frosted clear dome.

There are some people simulating the rotating part of the bussard collecte, but for me it doesn´t look very nice. So a combination of a motor for the rotating grill and some LED´s gives a much better effect.

Here is someone who made a PCB to mount all LED´s. But Im more interested in a Code for having some flashing, blinking, fading LED´s with some randomness like in the video.

https://www.youtube.com/watch?v=BucR-Cdlbos


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

@trace

 

Thank you Trace for uploading this. I'll be working on this shortly and testing everything out this weekend. Trying to get all the effects and lighting done before beginning the prep on the model.  Question for you, did you tie any of the nav lights into the arduino, do something separate for it, or none at all? I haven't looked at the coding yet so I apologize in advance if it's in there already. 

I'm also incorporating an Adafruit 24 Channel PWM driver module to control multiple effects (LED's linked to fiber optics)  inside of the model and some effects inside the base. 


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

@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.


   
ReplyQuote
Page 9 / 15
Share: