# Prop1 program - New take on some fire flies



## Garage-Of-Evil (Jul 24, 2007)

This is a different take on JonnyMac's very cool "fire flies" code. The intent of this version was to randomize the PWM ramp-up and down times to make the fireflies more natural. The "playlist" was also removed.

For those not familiar with this program, the use is simple. Run a bunch of grain-of-rice LED's off the Prop-1 5V pins, and arrange them in such a way so that a slight breeze, or perhaps even an FCG type mech makes the LED's move. The program then randomly lights the "fire flies". Very cool effect!

' =========================================================
'
' File: fire_flies2
' Purpose: A different take on the "fire flies" LED program
' Author: Steve O'Connor
' E-mail: [email protected]
' Started: August 27, 2007
' Updated: N/A
'
' {$STAMP BS1}
' {$PBASIC 1.0}
' {$PORT COM1}
'
' =========================================================

' -----[ Program Description ]---------------------------------------------
' My version of JonnyMac's very cool fireflies program. The intent of this
' version was to randomize the PWM ramp-up and down times to make the fireflies
' more natural. The "playlist" was also removed.

' -----[ Revision History ]------------------------------------------------
' N/A
' -----[ Variables ]-------------------------------------------------------

SYMBOL Bug = B2
SYMBOL Lottery = W5
SYMBOL  Brightness = B4
SYMBOL PINCheck = B3
SYMBOL WaitTime = W6
SYMBOL Duration = B1
SYMBOL Duration_Stir = B8
SYMBOL Startdur = B7

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

Main:

FOR Duration_Stir = 1 TO 10 'Stir the variables up

RANDOM Duration
RANDOM startdur
RANDOM Lottery
NEXT

Bug = Lottery // 6
Startdur = Startdur // 255
Duration = Duration // 256 + 150

IF PINCheck = Bug THEN Main 'Don't light the same Bug
'twice in a row

FOR Brightness = Startdur TO Duration STEP 1 'Light the Bug
PWM Bug, Brightness, 1
NEXT

HIGH Bug
PAUSE 300

FOR Brightness = Duration TO Startdur STEP -1 'Fade the Bug
PWM Bug, Brightness, 1
NEXT

RANDOM Lottery 'Stir Lottery again
WaitTime = Lottery // 250 + 500 'Use Lottery value for the
PAUSE WaitTime 'time between Bugs being lit

PINCheck = Bug 'Remember which Bug lit last

GOTO Main

' -------------------------------------------------------------------------


----------

