October 31, 2024, 05:53:29 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Fading running lights Etc for prop 2

Started by imagineerdan, November 08, 2007, 04:16:35 PM

Previous topic - Next topic

imagineerdan

I want that kind of randomness but to go in the order from pin0 -  pin14 one after another like the code below but not like it in its uniformity, is this possible


Chaser:

  FOR theLamp = 0 TO 14                         ' loop through low outputs
    FOR level = 255 TO 0 STEP 8                 ' bright to dark
      PWM theLamp, level, 10
    NEXT
  NEXT
  GOTO Chaser

JonnyMac

Sorry, Dan, my head been in the clouds with another very big project.  Of course, a FOR-NEXT loop will work.  Try it like this:

Chaser:
  FOR theLamp = 0 TO 13                         ' loop through outputs
    RANDOM lottery
    speed = lottery // 6 + 5
    FOR level = 255 TO 0 STEP 8                 ' bright to dark
      PWM theLamp, level, speed
    NEXT
  NEXT
  GOTO Chaser


I put the "speed" variable back in to the cycles parameter of PWM to change the PWM timing of the LED.  The RANDOM function is called in every loop so the speed will change, LED to LED.
Jon McPhalen
EFX-TEK Hollywood Office

imagineerdan

November 30, 2007, 07:27:46 PM #17 Last Edit: December 01, 2007, 04:14:22 PM by imagineerdan
Looks great Jon and I am understanding the programming pattern step by step. Thanks! :)

If I were to have all the LEDS on high then fade them off one by one sequentially with this type of code, how would I do that?

JonnyMac

I posted code for that in your new thread -- it's really easy (make the pins outputs and then turn them all on).
Jon McPhalen
EFX-TEK Hollywood Office