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
(@trace)
Estimable Member
Joined: 5 years ago
Posts: 170
 

Tricorder


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

Sorry for no daily replies haha ... 
I've been very busy with another project which I'd like to finish.

Man, you are giving me way too many new ideas for super cool projects.
Love the radar and the Tricorder is absolutely awesome! 

In the meanwhile I did receive the components (MP3 player etc), and even though it is completely against my nature: it's still laying on the table, waiting for me to start playing with it.
Like I said; I'm working on a huge project which I'd like to finish.
If only one or the other millionaire would could sponsor me so I could make this my day-time job! 

Oh and because of Picard, I started watching the 2003 show "Star Trek Enterprise" ... again (must be the 4th time now). I do need my "unwind" time haha.
I really loved that show, and I'm not patient enough to wait for a week each time to see the next Picard episode (which I'm watching - only 4 episodes so far though).
Definitely enjoying Picard more than "The Mandalorian" (which wasn't bad either).


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

My week is also very busy, so it is ok not to reply as quickly as possible.

And I even did not start to build the Enterprise. So we have enough time haha.

"..... still laying on the table, waiting for me to start playing with it...." - that´s what she said

And I thought stuff like this is kinda your daily job.

The millionaire could sponser us, not our projects haha

What I don´t like about "Star Trek - Enterprise" is the intro....but the show was nice and it really felt like pre-Kirk.

Maybe in the future I will get Netflix or Amazon or so. So I can talk about all these great shows too haha

Have a nice weekend. And I was able to only use one line for each topic 


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

I finally managed to get a beta release ready of that major project ... so now I'm waiting for response of testers.
I hope I'll find some time today to play with my Arduino "plank". 
Then again; finding a replacement forum is high on the "To Do" list as well. 

At the moment, developing tools and maintaining my website, have turned into a fulltime job.
The only problem with that is that my bank-account gets drained hahah.
This is where this millionaire should come in and feed my bank account every now and then so I can keep paying rent and get myself some food hahaha. 

"Star Trek - Enterprise" feels like a set of stories, like we have seen in the original series. Exploring other worlds, combined with an overlaying story line.
I've just watched all 4 seasons again. I really liked it, and it is too bad they cancelled it. I'm still confused why it's called "bad" by some reviews, but then again, we all have our taste in things haha. There are a few reasons why I gravitate more towards Star Trek than Star Wars. Star Wars (with the exception of the first movie) always has been rather "slow" and too many people seem to be purists and complain about everything. For me it's about enjoying a good story ... and Star Trek fits the bill for me .

It's almost weekend again (just kidding!) - enjoy your week. 


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

Planking.....wasn´t it a thing a few years ago? 

The
weeks are passing buy in no time and im glad if I don´t fall asleep as
soon as Iam at home and my legs go up in a horizontal arrangement 
So I had no time for the Star Trek project to figure the warp and torpedo effect out by my own. But Im sure it will happen.

What about addings some adds to your website to get some extra money for this (I have no clue about all of that)?

I
think the problem with Star Trek Enterprise was that most people missed
the Star Trek vibe....like in the new movies or Discovery....but it
worked for me, because it really felt like pre-Star Trek. So I had no
problem "without" the Star Trek atmosphere. But in the new movies and
Discovery...well...it wants to be Star Trek so hard, that it feels off
in some cases.
Take a look at some "Star Trek vs. Discovery" videos on youtube and you will have a red forehead because of the many facepalms.

I wish I could say the next one is from me. But it is not. Somewhere in a comment I have read:

"Star Wars is for entertaining....Star Trek is for inspiring"

For
me, this is the most accurate difference between Star Trek and Star
Wars. And I have to say I really really like the old Star Wars movies
(IV-VI).

Well monday is the beginning of the end of the week....so yeah...happy weekend to you.

PS: if this gets posted, than it is about the smileys again. Weird.


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

Hahaha to funny! I forgot about planking.

Based on your fun experiences with the forum, I've been working on that now as well.
I ran into a forum that may do the trick, but I need to do some work to migrate the data and make it fit my website theme.

So I know how it is to come home and almost pass out ...

I've added ads from Google and Amazon. It does generate a little income, but it just about covers hosting, domain registration and SSL certificates.
It is far from something I could live from. 
I would however LOVE to set up shop with a couple of people and expand the website.
It seems that the (unintended) formula is appreciated by a lot of folks, and figuring out issues with other people is really fun to do.

Haha, yeah, see this is where I'm more aiming at enjoying a TV Show or a movie.
There may be inaccuracies, or even annoying things, but as long as I enjoy the Show/Movie: I'm all good.
I actually feel that Enterprise is more Star Trek than the 2 more recent show - but I enjoy them all.

That is an interesting quote ... I actually feel that Star Wars is pretty, just that and nothing more (with the exception of the old episodes - those were awesome).
Where as Star Trek is entertaining, fun and inspiring. On top of that: with Star Trek I feel like it is something I could be doing in a different life.

Enjoy your rest of the week ... 

(and I hope to have the new forum up and running next week ... it is still a lot of work)


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

Good to read that you are near to a forum solution. I hope the new forum will be able to handle everything you want.

With your planking link, i realized that this is about 10 years old and that makes me feel old too (35) hahaha

To be able to live from ads you need to make a youtube channel but not with arduino and electronics. Just react to some other content....but this will only work if you are under 30 and look like a model and behave like a 12 year old child with midlife crisis hahahaha

Star Trek is more about how to live and work together and how to find a solution for problems and how to handle bad situations. I think thats why it is so much more inspiring. But because of Star Trek and Star Wars never meant to play in the same league, it is hard to compare both. And maybe it is not neccessary as long as it is entertaining....the one or the other way.

I was also thinking about the Radar display. From what I know it is not possible to play a videofile by only using arduino. But what about GIF?!

Im curious about next week and the new forum. Im sure you will get the goal.


   
ReplyQuote
(@bleuraeder)
New Member
Joined: 5 years ago
Posts: 2
 

Great thread and great topic! But there is one thing missing unless I somehow missed it. Is there a parts list and pinout for the Arduino?


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

Hi bleuraeder,

at page 2 you will find the whole code at #post-13374

I don´t know how much knowledge you have about Arduino, so I don´t know how much I need to describe.

There is no part list. But you only need an Arduino (i have used NanoV3), a WS2812 strip (Neopixel Strip), the DFPlayer mini (MP3-TF-16P), a speaker (<=3W) and of course power supply.

If you only want the light effect without sound, you don´t need the DFPLayer of course.

The data line from the WS2812 strip is connected to Pin7 of the Arduino. On Pin 3 is a push button. Then the DFPLayer uses a software serial, which means Pin 10 on the Arduino is used as RX and Pin 11 as TX. Pin 10 (RX) from the Arduino goes to Pin 3 (TX) from the DFplayer and Pin 11 (TX) goes to Pin 2 (RX). You should put a 1kOhm resistor between Pin 11 and Pin 2. And yes, RX from the Arduino goes to TX from the DFPlayer and TX from the Arduino goes to RX from the DFPLayer.

Now you need to connect the Speaker to Pin 6 and 8 from the DFPlayer.
You also need a microSD card with MP3 files.

How to put MP3 files to the SD card so the DFPLayer can read it, is described well in the instructions of the DFPLayer. Just google "DFPlayer mini PDF"

Feel free to ask any questions you have.


   
ReplyQuote
(@bleuraeder)
New Member
Joined: 5 years ago
Posts: 2
 

Perfect @Trace, that is exactly what I was looking for.


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

You are welcome.


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

@Trace: I've implemented a new forum - hope you like it.
I'm still in the process of fine tuning the last pieces ... any comments/suggestions are welcome! 😊 


   
ReplyQuote
(@chenjaya)
New Member
Joined: 5 years ago
Posts: 2
 

@hans

Thank you for your article about Star Trek Phaser Array.

I've tried, but got some error messages like these :

In file included from C:\Users\Acer\Documents\Arduino\PHASER\PHASER.ino:1:0:
C:\Users\Acer\Documents\Arduino\libraries\FastLED-3.3.2/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.002
# pragma message "FastLED version 3.003.002"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Acer\Documents\Arduino\PHASER\PHASER.ino: In function 'void setAll(byte, byte, byte)':
PHASER:134:33: error: incompatible types in assignment of 'CRGB' to 'CRGB [60]'
leds = CRGB(red, green, blue);
^
exit status 1
incompatible types in assignment of 'CRGB' to 'CRGB [60]'

 

Any suggestion how to fix them ?

Thank you and have a nice week end.

 

Chen


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

@chenjaye - would you be able to attach the code you're trying to compile?

At first glance I see there is no index used with the "leds" array.

For example:

leds = CRGB(red, green, blue);

Should be something like:

leds[i] = CRGB(red, green, blue);

Since I'm not aware of the context code, you'll have to find what "i" should be, most likely you are looking at these 2 functions:

void setPixel(int Pixel, byte red, byte green, byte blue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.setPixelColor(Pixel, strip.Color(red, green, blue));
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
 #endif
}
void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

Where the setAll function has been changed.

Tip:

Since you're using FastLED, the setAll() function, you can optionally replace the "setAll()" function with the build in "fillSolid" function from the FastLED library (probably faster as well).

Example, instead of calling

setAll(red,green.blue);

you could do this (and skip the entire "setAll()" function definition in your code):

fill_solid ( leds, NUM_LEDS, CRGB(red,green,blue) );

Hope this helps.


   
ReplyQuote
(@chenjaya)
New Member
Joined: 5 years ago
Posts: 2
 

@hans Hello Hans

 

Thank you so much for your quick reply.

I used your whole codes  as below, but got error messages as mentioned earlier.

 

Regards,

Chen

 

#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); // 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) 
{
  // 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 = CRGB(red, green, blue);
  }
  
  FastLED.show();
}

   
ReplyQuote
Page 6 / 15
Share: