May 20, 2024, 12:21:56 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 Led's in my Pumpkins

Started by ravenscroft, August 22, 2007, 09:09:30 AM

Previous topic - Next topic

ravenscroft

My question:

I have an Idea for my fake pumpkins this year.  I want to have LED's in my pumpkins with 6 different colors fading between each.  I want it to start with one color then fade out while the next color fades in.  And I want that to happen over and over.  Can Vixen handle this or do I have to program it in basic?  If I have to do it in Basic I will need some help.  I will have to play with the timing to get it right but I can do that over the next few months.

Jon's answer:

You can't do it with the Vixen GUI for the Prop-1 and Prop-2 because that is
for straight on-off sequences (like a mini-brick).  To be able to fade between
to LEDs at the same time will take a Prop-SX and some tricky programming -- I
can do the tricky part for you.  Now... if you can deal with fading one LED up
or down at a time, we have code that will work on the Prop-1; that's how we do
our mood skull.


New question:

Can I try the program for the fading one at a time, to see if I want to use that or buy the Prop-SX?

JonnyMac

I think this does what you want.

' =========================================================================
'
'   File...... Pumpkin_Leds.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Leds            = PINS
SYMBOL  Led5            = PIN5
SYMBOL  Led4            = PIN4
SYMBOL  Led3            = PIN3
SYMBOL  Led2            = PIN2
SYMBOL  Led1            = PIN1
SYMBOL  Led0            = PIN0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  ledOn           = B2
SYMBOL  ledOff          = B3
SYMBOL  level           = B4


' -----[ Initialization ]--------------------------------------------------

Reset:
  Leds = %00000000
  DIRS = %00111111

  Led5 = IsOn

' -----[ Program Code ]----------------------------------------------------

Main:
  ledOff = ledOn + 5 // 6                       ' -1 with rollunder

Fade_Up:
  FOR level = 0 TO 255 STEP 1
    PWM ledOn, level, 1
  NEXT
  HIGH ledOn

Fade_Down:
  FOR level = 255 TO 0 STEP -1
    PWM ledOff, level, 1
  NEXT
  LOW ledOff

  ledOn = ledOn + 1
  IF ledOn < 6 THEN Main
    ledOn = 0
    GOTO Main


' -----[ Subroutines ]-----------------------------------------------------


' -----[ EEPROM Data ]-----------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

ravenscroft

Cool I will give it a try either tonight or the weekend(which is more likely).

ravenscroft

August 28, 2007, 10:13:58 AM #3 Last Edit: August 28, 2007, 10:15:39 AM by ravenscroft
Am I able to use the Outs for the LEDs or do I have to use the PINs?  I'm wondering because I will be running 12vdc to all the LEDs and I thought the PINs were for lower voltages.  I'm just asking before I fry something.  And if I can, do I just switch Symbol : PINS to OUTS and then switch all of the PINs in the sequence to OUTs?

P.S. I liked the way it worked for now, of course I will have to get the SX in the future so I can have a seamless transition between colors.

JonnyMac

You can use the OUTx terminals, in fact, that will let you run more LEDs per channel and with more current.  You don't have to change the code at all -- the UNL2803 buffers the pins to the OUTx terminals.

Here's a schematic that shows how to connect one, two, or three LEDs to an OUTx pin, and the resistor required to limit the current to a safe level.

Jon McPhalen
EFX-TEK Hollywood Office

ravenscroft


ravenscroft

OK so I was happy with this program, I was doing great had everything built just the way I wanted it to work.  Then I had to show it off to some friends.  They said they didn't like how it kept fading constantly.  So now I have to ask, Can I add a pause in the program to leave it on one color for say 10 sec.?  Of course what would really work would be to never show stuff to my friends again. :-\  Is this possible?  If not then I will just order the darn SX and be done with it.

JonnyMac

September 28, 2007, 10:17:26 AM #7 Last Edit: September 28, 2007, 10:25:04 AM by JonnyMac
Should the delay be added at the end of the cycle? -- and wouldn't it be more interesting if it was randomized?

Update: Keep in mind that I've probably written about 100 programs since I did yours, so I had to spend a minute re-familiarizing myself with it.  In your program, you have either one or two LEDs on at any given time.  When you say "stop on one color" what does this mean? One Led -- or two?  Checking the state of the LEDs is possible, but you have to do it differently if you're looking for two LEDs vs just one.  Let me know and I'll update your program.
Jon McPhalen
EFX-TEK Hollywood Office

ravenscroft

Quote from: JonnyMac on September 28, 2007, 10:17:26 AMKeep in mind that I've probably written about 100 programs since I did yours

I don't doubt it.   :o  I imagine this is a tough time of year for you, AND WE ALL APPRECIATE WHAT YOU DO FOR US ALL!!!!!!!!!!!!!!!!!!!


OK, programming.  this is what I was thinking of:
start  LED 1 ON
pause 10 sec
LED 2 fade up
LED 1 fade down
pause 10 sec
and so on and so forth.........

I figure since the prop-1 can't cross fade this would be easier ;D

JonnyMac

September 28, 2007, 07:39:19 PM #9 Last Edit: September 28, 2007, 08:19:21 PM by JonnyMac
If you can show me a $35 BASIC language controller that does do cross-fading and comes with the support we give with the Prop-1, I'll eat a bug. 

Before you insert artificial pauses, try extending the PWM command by changing the cycles parameter from 1 to 5 -- this may get you closer to what you're looking for.

Fade_Up:
  FOR level = 0 TO 255 STEP 1
    PWM ledOn, level, 5
  NEXT
  HIGH ledOn

Fade_Down:
  FOR level = 255 TO 0 STEP -1
    PWM ledOff, level, 5
  NEXT
  LOW ledOff
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

September 28, 2007, 08:15:35 PM #10 Last Edit: September 28, 2007, 08:17:20 PM by JonnyMac
If that doesn't do it, insert PAUSE 10000 between the Fade_Up and Fade_Down sections:

Fade_Up:
  FOR level = 0 TO 255 STEP 1
    PWM ledOn, level, 1
  NEXT
  HIGH ledOn

  PAUSE 10000

Fade_Down:
  FOR level = 255 TO 0 STEP -1
    PWM ledOff, level, 1
  NEXT
  LOW ledOff

  ledOn = ledOn + 1
  IF ledOn < 6 THEN Main
    ledOn = 0
    GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office