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 most likely no translated for the post!




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

LED Effects - Star Trek Phaser Array

Page 12 / 13

(@trace)
Trusted Member
Joined: 1 year ago
Posts: 83
 

@hans

 

The first effect we had was the Phaser effect. 2 LEDs running down the strip from its ends to a random shooting point. The second effect was the Warp effect.

And I just realized, that this effect could also been used for a torpedo shoot. So in total we have 3 effects while Warp and Torpedo are the same just with different timings and colors (and sound of course).

3 effects, 3 buttons. The rotary switch (for selection) is an interesting idea, but not for this project. I plan to have something like a console (so called LCARS) with 3 labeled fields and 3 capacitive switches, so it feels like a touchpanel. Take a look at this video and you will know what I mean:

Which other Torpedo effect do you mean? Do I overlook something? The Enterprise-D, which Iam building, has just one Torpedo Launcher at the front (and one at the back). So one single WS2811 is enough because Im not planning to have the rear Torpedo to shoot. But in case of some other ships, many have two torpedos at the front, firing alternately left and right with a little pause between left and right (The Voyager jackmtaco is planning to build for example).

 

Maybe another effect could be nice (4th button). Firing all weapons. So like it shoots a burst of phasers (maybe shorter running, so it doesn´t need to have the LEDs running all the way from each end to the aiming point), then two torpedoes, then one or two phasers again, all with one single push of a button.

Like in this video:

With the interrupt, is it like I have pushed the button for Phaser and while the effect is running I push the button for Warp so the Phaser stops and Warp is running and then after the Warp effect is finished, turning back to Phaser to finish this effect?
I think this isn´t needed for our types of effects, because every effect is a hit and go without the need of interrupt. But im curios to learn about it.


ReplyQuote
(@jackmtaco)
New Member
Joined: 5 months ago
Posts: 0
 

Haven't forgotten about you all! Hope you're doing well. Took a small break from the arduino as I just got a new 3D resin printer I've been toying with. Still plan to come back to working on this at the beginning of the year. Hope you all have a great holiday! 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1845
Topic starter  

No worries jackmtace! Hope you're doing well as well. 😊 

Oh, a resin printer, nice! Which one did you get? Please share your experiences!
I've been eyeballing the Elegoo Saturn for a while now (not available at the moment) after having some mediocre experiences with FDM printers.

Y'all stay healthy now! 👍  😉 


ReplyQuote
(@trace)
Trusted Member
Joined: 1 year ago
Posts: 83
 

@hans Hi there and happy new year! Hope you are doing well?!

I was just curious to see if something new happened here and was about asking if there is any progress in our complex effect program? But I don´t "need" it at the moment, so no hurry, no rush and have a nice Sunday :D


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1845
Topic starter  
Posted by: @trace

I was just curious to see if something new happened here and was about asking if there is any progress in our complex effect program?

Hi Trace: Happy new Year!

I'll be honest: I totally forgot about it and even had to scroll back to see what you were referring to 😱  
The past few weeks have been quite chaotic and I'll try to find some time to look into this.

Finding a job (no luck so far) and several holidays (ThanksGiving, Sinterklaas, Christmas, New Year, birthday of my nephew, etc) have prevented me from tinkering with this 😣 


jackmtaco liked
ReplyQuote


(@trace)
Trusted Member
Joined: 1 year ago
Posts: 83
 

@hans

As I said...no hurry....it is not that important or urgent or anything like that. I was just curious. And because of all the holidays, I did not follow this thread either.

No luck by finding a job? With your skills about programming? That sounds hard, sorry to hear that.

But I have to say I kinda feel like I also want another job. It is not like i dont like what Im doing, but it is a lot of work for too less money and all year long there are the same problems again and again without the need to change anything by the management and that´s depressing.


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1845
Topic starter  

@Trace

Covid makes it more of a challenge for me. I'm "stuck" in Holland for now, and am looking for work at home (US).
As you can imagine, this comes with challenges.

Sounds like you need a change of scenery as well 😉 
One of my last jobs had challenges like that as well. You know what needs to be changed, but nobody listens and the same sh*t keeps happening over and over again.
Thank goodness this was just a temporary job (cleaning up a company, making it ready for being sold).
I'm sure there are opportunities out there - just finding them can be a challenge.

Alos note: my programming skills are just a hobby. I'm more in IT management.
Having learned my lessons, I'm looking for a smaller company with IT management needs. 😉 


jackmtaco liked
ReplyQuote
(@janesmouse)
New Member
Joined: 2 years ago
Posts: 0
 

HI,

I have been trying to adapt this to work with a 60 LED Dotstar ring with little success. I was able to use a standard 24 LED Neopixel ring with no problem and my Dotstar ring is working with a selection of other sketches using Fastled. Am I doing something wrong?

Here is my modified code, the only real differences are at the beginning and in the setup.

Thanks in advance

#include "FastLED.h"
//#include <EEPROM.h>

#define LED_TYPE        DOTSTAR
#define NUM_LEDS      60
#define CLK_PIN          1
# define DATA_PIN       0
#define COLOR_ORDER BGR

CRGB leds[NUM_LEDS];

void setup()
{
FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection( TypicalLEDStrip );
randomSeed(analogRead(0)); // for a better random
randomSeed(analogRead(0)); // for a better random

}
void loop()
{
startrek_phaser( 0xff, 0x80, 0, -1, 3, 3, 20, 20, 60, 40); // TargetLED = -1 = random pick
delay(200); // 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)
{
// 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

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( 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);

}
}
// 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();
}


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1845
Topic starter  
Posted by: @janesmouse

I have been trying to adapt this to work with a 60 LED Dotstar ring with little success. I was able to use a standard 24 LED Neopixel ring with no problem and my Dotstar ring is working with a selection of other sketches using Fastled. Am I doing something wrong?

Welcome to the forum 😊 

With your current code; what is going wrong? Are you seeing anything?

I'm not familiar with the AdaFruit Dotstar products, but what I understand from the FastLED documentation these are APA102 LED strips.
So that is one thing you could try;

#define LED_TYPE APA102

Another thing you could try:
Test the code for your 24 LED Dotstar. When that works, without changing the code (so leave NUM_LEDS = 24) try this with the 60 LED Dotstar.
I know this is not the right amount of LEDs, I'm just curious if the 24 LED Dotstar is technically maybe different than the 60 LED DotStar.
When I worked on the code, I did my testing with a 60 LED WS2812 strip, and that worked correctly. 🤔 


ReplyQuote
(@janesmouse)
New Member
Joined: 2 years ago
Posts: 0
 

Hi Hans,

Not sure of the problem, it compiles correctly, uploads to the board but no display. I've tried the mods you suggested but nothing changed.

So far I have had it running on a 30 led strip and the 24 led ring which is neopixel and not Dotstar. 

Using the serial monitor just before fastled.show() I can see the RGB values and the LEDPos changing so the problem seems to be with the display section. This is confirmed when running other sketches which do work, if I load the phaser sketch while another is running the ring holds it's last data unchanged. The dotstars seem to dislike something in the code.


ReplyQuote


(@janesmouse)
New Member
Joined: 2 years ago
Posts: 0
 

Hi Hans,

Solved it!

I was using Pin 0 for Data and Pin 1 as Clock for the leds. Commented out the randomseed commands and it works fine now. 

I'll change the pins to add the random back in. Next part is to get it to wrap round when it hits 59 . I love this sketch :-)

 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1845
Topic starter  
Posted by: @janesmouse

Solved it!

Awesome!
For adding randomness back, you could try calling the random seed calls before setting up the LED strip or use a different pin for the random value. I believe it has to be an analog pin, but I'm not sure what Arduino model you're using. On an Arduino Uno you could try Pin 2 for example.


ReplyQuote
(@janesmouse)
New Member
Joined: 2 years ago
Posts: 0
 

Just need to slide the Clock wire to Pin 2 and it will be fine. 

Currently playing with Adafruit Trinket M0, lovely little board.


Hans liked
ReplyQuote
(@murad)
Eminent Member
Joined: 3 months ago
Posts: 24
 

good job guys


ReplyQuote
(@snooker216)
New Member
Joined: 1 month ago
Posts: 4
 

Hi everyone,

I am actually working on the build of a U.S.S. Voyager in scale 1/670 Revell set.

My plan to realize the phasers is a little bit different. Because the color of the Phasers is not really changing i will use 0402 SMD LEDs in orange controlled seperately. To have enought ports to control them I will use an

Arduino Mega. I plan to use 20 LEDs on each upper phaser bank. And I will select randomly if the right or left half will fire. To achieve this I will control the power for the LEDS via PWM over a Mosfet. So I have

the possibility to control the flickering at the end of the firing sequence.

The phasers of the voyager don't have this moving sequence from both sides to the final firing point. So the programming should not be that difficult. At least I hope so.

The navlights i will outsource to an ATTiny85-20. So I can avoid any delay programming.

Reading here i wondered for what scale you are developing. Realising this with a RGB LED strip in a 1/670 Voyager i find more than only challenging.

In the final stage I want to control this all with an LCARS touch panel. But at the moment I have no idea how to do this.


ReplyQuote


Page 12 / 13

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: