Welcome, %1$s. Please login or register. - Did you miss your activation email?

Login with username, password and session length
 

Author Topic: Viper Engines- Ramp up and flicker  (Read 273 times)

Offline Spencer

  • Physicist and Astronomer
  • Admiral
  • *****
  • Posts: 590
  • "Well ... let's play this out logically then ..."
    • My Google+ Page
Re: Viper Engines- Ramp up and flicker
« Reply #15 on: October 16, 2017, 12:12:27 pm »
@whb64
I know all about work ... Will take a look at those pictures when you put them up.


@texastony1946
I've modified the code to exclude the use of delay(). See below ...

Note that it's only for one output pin. If you want multiple outputs all flickering the same, you can just duplicate things as whb64 has.
If you want them to all flicker differently, you'll need to duplicate the various commands and blocks of code for each LED separately. I leave that for
you to try if you need it ...


Spencer




#define LED_FLICKER_PIN 10
//sets the variable "LED_FLICKER_PIN to pin 10, needs to be a pwm pin;

// this is the brightness when the led "dips", will be between lowest_low and highest_low
static int lowest_low=80;
static int highest_low=120;

// this is the brightness when the led "peaks", will be between lowest_hight and highest_high
static int lowest_high=70;
static int highest_high=255;

// time led is at peak, between shortest_on and longest_on
static int shortest_on=40;
static int longest_on=80;

// time led is at dip, between shortest_off and longest_off
static int shortest_off=40;
static int longest_off=80;

// time to fade up, in milliseconds
static int fade_time=1500;
static int step_time = int(float(fade_time/255));

// time keeping
unsigned long currentMillis;
unsigned long flickerMillis;

// various bookeeping things
boolean led_flicker_state = 0;
int on_time;
int off_time;
int high_brightness;
int low_brightness;
int fade_brightness;


void setup() {
  // set pin as output
  pinMode(LED_FLICKER_PIN, OUTPUT);

  // intially randomize the params
  low_brightness = random(lowest_low, highest_low);
  high_brightness = random(lowest_high, highest_high);
  on_time = random(shortest_on, longest_on);
  off_time = random(shortest_off, longest_off);
}



void loop() {
  // get the time
  currentMillis = millis();
 
  // first do a fade
  if (currentMillis <= fade_time){
    fade_brightness = int(255.0 * float(currentMillis) / float(fade_time));
    analogWrite(LED_FLICKER_PIN,fade_brightness);
  }

  // then the flicker
  else{

    // When it's time to change states, write it out, reset the time and randomize again
    //    for the next time to change states
    if (currentMillis - flickerMillis > (led_flicker_state ? on_time : off_time)){
      analogWrite(LED_FLICKER_PIN, (led_flicker_state ? high_brightness:low_brightness));
      flickerMillis = currentMillis;
      led_flicker_state = !led_flicker_state;
      low_brightness = random(lowest_low, highest_low);
      high_brightness = random(lowest_high, highest_high);
      on_time = random(shortest_on, longest_on);
      off_time = random(shortest_off, longest_off); 
    }
 
  }

}

Offline MarkW

  • Plastic Surgeon
  • Admiral
  • *****
  • Posts: 1336
    • MW ModelWerks
Re: Viper Engines- Ramp up and flicker
« Reply #16 on: October 16, 2017, 03:39:30 pm »
THIS THREAD IS USELESS WITHOUT THE VIDEO.

 ;D ;D ;D ;D ;D ;D
MarkW
"I can cross stab Hitler to death off the list of cool crap I thought I'd never do"
--Brock Sampson
NEW WEB ADDRESS

Offline Spencer

  • Physicist and Astronomer
  • Admiral
  • *****
  • Posts: 590
  • "Well ... let's play this out logically then ..."
    • My Google+ Page
Re: Viper Engines- Ramp up and flicker
« Reply #17 on: October 16, 2017, 03:55:15 pm »
@Mark

I do have some rather crappy video of my code. Note the flickering is exaggerated!

Flicker by Spencer Wolfe, on Flickr

Offline whb64

  • Captain
  • ****
  • Posts: 394
Re: Viper Engines- Ramp up and flicker
« Reply #18 on: October 16, 2017, 05:52:53 pm »
Don't mind my messy work bench!

This is a picture of the LED array I am using


And here is a video of the array firing up
https://youtu.be/JPycG2tUp_A
« Last Edit: October 16, 2017, 06:09:15 pm by whb64 »

Offline texastony1946

  • Ensign
  • *
  • Posts: 24
Re: Viper Engines- Ramp up and flicker
« Reply #19 on: October 17, 2017, 06:29:44 am »
Thank you for the code wnhb64 and Spencer. I have been working on a fade flicker that would ramp the engines up and flicker as the fade up happens, this would fade the flicker as the ramp takes place and achieve max brightness at max fade. I will play with the code and see if I can use to make this happen. Thanks again for your efforts and the code.

Offline texastony1946

  • Ensign
  • *
  • Posts: 24
Re: Viper Engines- Ramp up and flicker
« Reply #20 on: October 17, 2017, 06:42:34 am »
Sorry I left this out, This is a simiiar effect I am trying to achieve. This guys work is awesome.Thanks
https://www.youtube.com/watch?v=92YmkG-RSBE

Offline MarkW

  • Plastic Surgeon
  • Admiral
  • *****
  • Posts: 1336
    • MW ModelWerks
Re: Viper Engines- Ramp up and flicker
« Reply #21 on: October 17, 2017, 03:07:34 pm »
Don't mind my messy work bench!

This is a picture of the LED array I am using



Did you etch your own PCBs, or were they from a kit?
MarkW
"I can cross stab Hitler to death off the list of cool crap I thought I'd never do"
--Brock Sampson
NEW WEB ADDRESS

Offline whb64

  • Captain
  • ****
  • Posts: 394
Re: Viper Engines- Ramp up and flicker
« Reply #22 on: October 17, 2017, 03:11:54 pm »
They are from a $1 flashlight from Walmart :)

Offline whb64

  • Captain
  • ****
  • Posts: 394
Re: Viper Engines- Ramp up and flicker
« Reply #23 on: October 17, 2017, 08:42:09 pm »
This is the flashlight taken apart and the parts you get



All for $1 :)

 




Enterprise © Bloc