November 22, 2024, 02:44:31 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Hey Jon...can you take a look at this code you wrote..????

Started by Eric, April 02, 2007, 09:34:23 PM

Previous topic - Next topic

Eric


Hello..you wrote this a while back for me....there seems to be problem. The Prop1 runs the routine all the time and does use the PIR...it just loops the output sequence as soon as power is supplied...I have tried changing things....but seem to be missing something....What do you think ??

Please help.. its due Tuesday night !! Yikes

Thank You,

Eric




' =========================================================================
'
'   File...... Pigmy-Darts.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 26 JAN 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PIR             = PIN7                  ' SETUP = DN
SYMBOL  Blower          = PIN1                  ' connect to V+/OUT1
SYMBOL  Pigmy           = PIN0                  ' connect to V+/OUT0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  BlowOn          = 150                   ' blow valve on-time
SYMBOL  BlowOff         = 75                    ' blow valve off-time

' Note: BlowOn + BlowOff must be less than 300.


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

SYMBOL  pirTimer        = B2                    ' for PIR debouncing
SYMBOL  secs            = B3                    ' 0 to 255 seconds
SYMBOL  darts           = B4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' P0 and P1 are outputs


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 25
  pirTimer = pirTimer + 25 * PIR                ' update/clear timer
  IF pirTimer < 250 THEN Main                   ' wait for 1/4 sec signal
    pirTimer = 0                                ' clear for next cycle

Pre_Delay:
  secs = lottery // 3 + 1                       ' wait 1 to 3 seconds
  GOSUB Run_Timer

Get_Em:
  Pigmy = IsUp
  secs = 1                                      ' let pigmy rise
  GOSUB Run_Timer

Blow_Darts:
  RANDOM lottery                                ' restir
  darts = lottery // 11                         ' 0 to 10 darts

Shoot_Again:
  IF darts = 0 THEN Hide
    Blower = IsOn
    PAUSE BlowOn
    Blower = IsOff
    PAUSE BlowOff
    darts = darts - 1
    GOTO Shoot_Again

Hide:
  Pigmy = IsDown

Post_Delay:
  RANDOM lottery                                ' restir
  secs = lottery // 91 + 30                     ' wait 30 to 120 secs
  GOSUB Run_Timer
  GOTO Main


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

Run_Timer:
  IF secs = 0 THEN Timer_Done
    PAUSE 1000
    secs = secs - 1
    GOTO Run_Timer

Timer_Done:
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

JonnyMac

It's an easy fix -- after setting up the I/O pins you need to jump to the Post_Delay section; this will let you clear the area so that the PIR is not telling the prop to run when you apply power.

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' P0 and P1 are outputs

  GOTO Post_Delay


The GOTO line is the only addition you need to make.  It's also a good idea to let the PIR warm up before you want to use it and this delay provides time for that to happen.
Jon McPhalen
EFX-TEK Hollywood Office

Eric

Thank You Jon       <  see no "h"  this time

It worked.


Eric

Eric

Hello Jon...the plot thickens....Remember this code for the Pigmy guys:


'
'   File...... Pigmy-Darts.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 26 JAN 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PIR             = PIN7                  ' SETUP = DN
SYMBOL  Blower          = PIN1                  ' connect to V+/OUT1
SYMBOL  Pigmy           = PIN0                  ' connect to V+/OUT0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  BlowOn          = 150                   ' blow valve on-time
SYMBOL  BlowOff         = 75                    ' blow valve off-time

' Note: BlowOn + BlowOff must be less than 300.


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

SYMBOL  pirTimer        = B2                    ' for PIR debouncing
SYMBOL  secs            = B3                    ' 0 to 255 seconds
SYMBOL  darts           = B4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' P0 and P1 are outputs


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 25
  pirTimer = pirTimer + 25 * PIR                ' update/clear timer
  IF pirTimer < 250 THEN Main                   ' wait for 1/4 sec signal
    pirTimer = 0                                ' clear for next cycle

Pre_Delay:
  secs = lottery // 3 + 1                       ' wait 1 to 3 seconds
  GOSUB Run_Timer

Get_Em:
  Pigmy = IsUp
  secs = 1                                      ' let pigmy rise
  GOSUB Run_Timer

Blow_Darts:
  RANDOM lottery                                ' restir
  darts = lottery // 11                         ' 0 to 10 darts

Shoot_Again:
  IF darts = 0 THEN Hide
    Blower = IsOn
    PAUSE BlowOn
    Blower = IsOff
    PAUSE BlowOff
    darts = darts - 1
    GOTO Shoot_Again

Hide:
  Pigmy = IsDown

Post_Delay:
  RANDOM lottery                                ' restir
  secs = lottery // 91 + 30                     ' wait 30 to 120 secs
  GOSUB Run_Timer
  GOTO Main


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

Run_Timer:
  IF secs = 0 THEN Timer_Done
    PAUSE 1000
    secs = secs - 1
    GOTO Run_Timer

Timer_Done:
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------


Well the pigmy has been joined by 2 more pigmys.......The goal is:


1) a trigger input on pin 7

2) a yet to be determined delay starts

3) when the event starts, pigmys 1,2 or 3 pop up and shoot the air darts

4) At the end of the event Output 6 turns on (sprays a smell) for a adjustable duration

5) Event sequence ends and waits for next trigger input

NOW here are the Specifics:

(start delay after trigger is adjustable)

( the sequence and number of pigmy up at one time ....as well the number of .........shots fired by pigmy is totally random

( the total time they are up as well as the duration of the pulses that the air dart fires needs to be adjustable)

( during the event all pigmys will eventually be up together before the total event time ends)

( output 6 sprays a skunk smell after the pigmys are done.....duration adjustable)

pins are:

0 pigmy 1 up
1 pigmy 1 air dart fire
2 pigmy 2 up
3 pigmy 2 air dart fire
4 pigmy 3 up
5 pigmy 3 air dart fire
6 Smells on
7 Trigger input

What are your thoughts?

Thank You,

Eric

JonnyMac

Is the delay after the trigger simply adjustable, or is it randomized?  Is there an order to the pygmy selection, or is that randomized too?
Jon McPhalen
EFX-TEK Hollywood Office

Eric




:Is the delay after the trigger simply adjustable, or is it randomized?  Is there an order to the pygmy selection, or is that :randomized too?


The delay after the trigger is just adjustable it will be less than 15 seconds..... the Pygmy selection is random...The idea is for all 3 Pygmy to pop up in some random order that changes each time and when they are up shoot a random number of air bursts.

The effect is to simulate  an ambush of 3 Pygmy so each time the events happen in a different order.

E~


JonnyMac

Can the selected pygmies pop up at the same time?  I have a program started that will pop up 1, 2, or 3 pygmies, and doesn't repeat.   The thing is that with multiple pygmies they all pop up at once.  After their darts are expended they drop down.  So, while the pop up simultaneously, they drop when out of ammo so that can be in any sequence.  I'm having a tiny problem with the dart count and drop thing, but that won't take long to fix.  That said, I'm leaving for a road trip (taking work stuff with me), so I may not have this solved until this afternoon.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Okay, finally reconnected to the Internet and found the typo in my program that stopped it from working correctly.  In this version one, two, or three pygmies will pop up and each will be individually loaded with "darts."  While they all pop up at the same time (as in a coordinated attack) each will retract individually as it runs out of ammo.

' =========================================================================
'
'   File...... Pygmy_3x.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 15 FEB 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = out; no ULN
SYMBOL  Smellovision    = PIN6
SYMBOL  Dart3           = PIN5
SYMBOL  Pygmy3          = PIN4
SYMBOL  Dart2           = PIN3
SYMBOL  Pygmy2          = PIN2
SYMBOL  Dart1           = PIN1
SYMBOL  Pygmy1          = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  BlowOn          = 150                   ' blow valve on-time
SYMBOL  BlowOff         = 75                    ' blow valve off-time

SYMBOL  StinkTime       = 250


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

SYMBOL  pygmies         = B0                    ' pygmy group select
SYMBOL  last            = B1                    ' last group
SYMBOL  nDarts1         = B2                    ' dart counters
SYMBOL  nDarts2         = B3
SYMBOL  nDarts3         = B4

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %01111111                              ' make P0-P6 outputs

  timer = 0


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

Main:
  RANDOM lottery                                ' stir the pot
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 250 THEN Main                      ' wait for 0.25 sec input

Pre_Delay:
  timer = 150                                   ' 15.0 seconds
  GOSUB Run_Timer

Select_Pygmies:
  RANDOM lottery
  pygmies = lottery // 7 + 1                    ' create pointer (1 to 7)
  IF pygmies = last THEN Select_Pygmies         ' no repeats
    last = pygmies                              ' save for next cycle

Attack:
  READ pygmies, PINS                            ' jump up
  timer = 10                                    ' let pygmies rise
  GOSUB Run_Timer

Load_Darts:
  RANDOM lottery
  nDarts1 = lottery // 10 + 1 * Pygmy1          ' 0 to 10 darts
  RANDOM lottery
  nDarts2 = lottery // 10 + 1 * Pygmy2
  RANDOM lottery
  nDarts3 = lottery // 10 + 1 * Pygmy3

Shoot1:
  IF nDarts1 = 0 THEN Shoot2                    ' skip if out of darts
    Dart1 = IsOn                                ' shoot!
    nDarts1 = nDarts1 - 1                       ' update ammo count

Shoot2:
  IF nDarts2 = 0 THEN Shoot3
    Dart2 = IsOn
    nDarts2 = nDarts2 - 1

Shoot3:
  IF nDarts3 = 0 THEN Blow_Baby_Blow
    Dart3 = IsOn
    nDarts3 = nDarts3 - 1

Blow_Baby_Blow:
  PAUSE BlowOn                                  ' hold for air on-time

Breathe1:
  Dart1 = IsOff                                 ' dart off
  IF nDarts1 > 0 THEN Breathe2                  ' ammo left?
    Pygmy1 = IsDown                             '  no, hide pygmy

Breathe2:
  Dart2 = IsOff
  IF nDarts2 > 0 THEN Breathe3
    Pygmy2 = IsDown

Breathe3:
  Dart3 = IsOff
  IF nDarts3 > 0 THEN Deep_Breath
    Pygmy3 = IsDown

Deep_Breath:
  PAUSE BlowOff

Check_Pygmies:
  pygmies = PINS & %00010101                    ' scan pygmy pins
  IF pygmies > %000000 THEN Shoot1              ' if any standing, continue

Stink_It_Up:
  Smellovision = IsOn
  PAUSE StinkTime
  Smellovision = IsOff

Post_Delay:
  RANDOM lottery                                ' re-stir
  timer = lottery // 901 + 300                  ' wait 30.0 to 120.0 secs
  GOSUB Run_Timer

  GOTO Reset


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

' Timing in 0.1 second units

Run_Timer:
  IF timer = 0 THEN Timer_Done
    PAUSE 100
    timer = timer - 1
    GOTO Run_Timer

Timer_Done:
  RETURN

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


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


' -----[ User Data ]-------------------------------------------------------

Pygmy_Select:
  EEPROM (%000000, %000001, %000100, %000101)
  EEPROM (%010000, %010001, %010100, %010101)
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

After re-reading your response I wondered if what you're actually looking for is all three pygmies up for a given attack, but they pop up in random order.  This version does that, and even varies the offset a bit between each.  After all are popped the program works as before randomly loading each with darts, then they fire until they run out -- when a pygmy runs out of darts he immediately hides.

' =========================================================================
'
'   File...... Pygmy_3x-v2.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 16 FEB 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = out; no ULN
SYMBOL  Smellovision    = PIN6
SYMBOL  Dart3           = PIN5
SYMBOL  Pygmy3          = PIN4
SYMBOL  Dart2           = PIN3
SYMBOL  Pygmy2          = PIN2
SYMBOL  Dart1           = PIN1
SYMBOL  Pygmy1          = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  BlowOn          = 150                   ' blow valve on-time
SYMBOL  BlowOff         = 75                    ' blow valve off-time

SYMBOL  StinkTime       = 250


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

SYMBOL  pygmies         = B0                    ' pygmy group select
SYMBOL  last            = B1                    ' last group
SYMBOL  nDarts1         = B2                    ' dart counters
SYMBOL  nDarts2         = B3
SYMBOL  nDarts3         = B4
SYMBOL  pntr            = B5                    ' table pointer

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %01111111                              ' make P0-P6 outputs

  timer = 0


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

Main:
  RANDOM lottery                                ' stir the pot
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 250 THEN Main                      ' wait for 0.25 sec input

Pre_Delay:
  timer = 150                                   ' 15.0 seconds
  GOSUB Run_Timer

Select_Sequence:
  RANDOM lottery
  pntr = lottery // 6                           ' select, 0..5
  IF pntr = last THEN Select_Sequence           ' no repeats
    last = pntr                                 ' save for next cycle
    pntr = pntr * 3                             ' point to start of sequence

Attack:
  READ pntr, PINS                               ' pop a pygmy
  pntr = pntr + 1                               ' point to next
  RANDOM lottery
  timer = lottery // 151 + 100                  ' timer = 100 to 250
  PAUSE timer                                   ' short delay
  pygmies = PINS & %00010101                    ' scan pygmy pins
  IF pygmies <> %00010101 THEN Attack           ' wait for all to pop
    timer = 1000 - timer
    PAUSE timer                                 ' give last one full second

Load_Darts:
  RANDOM lottery
  nDarts1 = lottery // 10 + 1                   ' 1 to 10 darts
  RANDOM lottery
  nDarts2 = lottery // 10 + 1
  RANDOM lottery
  nDarts3 = lottery // 10 + 1

Shoot1:
  IF nDarts1 = 0 THEN Shoot2                    ' skip if out of darts
    Dart1 = IsOn                                ' shoot!
    nDarts1 = nDarts1 - 1                       ' update ammo count

Shoot2:
  IF nDarts2 = 0 THEN Shoot3
    Dart2 = IsOn
    nDarts2 = nDarts2 - 1

Shoot3:
  IF nDarts3 = 0 THEN Blow_Baby_Blow
    Dart3 = IsOn
    nDarts3 = nDarts3 - 1

Blow_Baby_Blow:
  PAUSE BlowOn                                  ' hold for air on-time

Breathe1:
  Dart1 = IsOff                                 ' dart off
  IF nDarts1 > 0 THEN Breathe2                  ' ammo left?
    Pygmy1 = IsDown                             '  no, hide pygmy

Breathe2:
  Dart2 = IsOff
  IF nDarts2 > 0 THEN Breathe3
    Pygmy2 = IsDown

Breathe3:
  Dart3 = IsOff
  IF nDarts3 > 0 THEN Deep_Breath
    Pygmy3 = IsDown

Deep_Breath:
  PAUSE BlowOff

Check_Pygmies:
  pygmies = PINS & %00010101                    ' scan pygmy pins
  IF pygmies > %000000 THEN Shoot1              ' if any standing, continue

Stink_It_Up:
  Smellovision = IsOn
  PAUSE StinkTime
  Smellovision = IsOff

Post_Delay:
  RANDOM lottery                                ' restir
  timer = lottery // 901 + 300                  ' wait 30.0 to 120.0 secs
  GOSUB Run_Timer

  GOTO Reset


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

' Timing in 0.1 second units

Run_Timer:
  IF timer = 0 THEN Timer_Done
    PAUSE 100
    timer = timer - 1
    GOTO Run_Timer

Timer_Done:
  RETURN

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


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


' -----[ User Data ]-------------------------------------------------------

Pop_Sequences:
  EEPROM (%000001, %000101, %010101)
  EEPROM (%000001, %010001, %010101)
  EEPROM (%000100, %000101, %010101)
  EEPROM (%000100, %010100, %010101)
  EEPROM (%010000, %010001, %010101)
  EEPROM (%010000, %010100, %010101)
Jon McPhalen
EFX-TEK Hollywood Office

Eric

Thank You Jon....

The second program IS what I was going for.... there seems to be a problem with the second and third pigmy doing the same thing at the same times... I am not sure why this is happening. there seems to be something not correct.

Oh....

The totals for everything worked out to be :

Delay after trigger input will be 3 seconds

Pigmy shots fired will be 0 to 3 per Pigmy

Does this also change anything ?

Thanks,

Eric



Eric

OK....Here is why I think they look weird when they actuate...its that the shots all start at the same time and all Pygmy lower at the end of the cycle at the same time. So here is what it should probably be like :

1)  trigger input on pin 7

2) delay 2 seconds

3) Pygmy pop up ( rise time is 3 seconds for a Pygmy to rise) in a random sequence and stay up until a random quantity (from 1 to 3 shots)  from each Pygmy is fired

4) when done firing each Pygmy lowers independent of each other (time is up time "3 seconds" + shots fired by Pygmy time then lower)

5) a delay then smellovision fires for 5 seconds

6) all deactivates and waits for next trigger input......no post delay is needed


I think this will solve the problems.

Eric

JonnyMac

So you want a pygmy to start firing as soon as he's up, even if the others are still popping up?  I think I can do this, but it makes for a programming style that you may find complicated (I have to use a state machine).  Let me run to Starbucks and then I'll give that a try.

Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Okay, Eric, I tried and there is no way to make the pygmies act completely independently (with a single Prop-1), i.e., start shooting while the others are still popping up.  There is just not enough memory or program space.  Of course -- as always -- I reserve the right to be wrong....

I have done a couple things to the program:

1) I added a play list to make sure all possible sequences are played before repeating -- this helps the apparent randomness
2) I added short delays after each firing pulse so that you can distinguish them; this should enhance the effect.

To get complete independence you should switch to the Prop-2; this has enough variable RAM and programming space to run a proper state machine which would allow each pygmy to be wholly independent after the sequence is initiated.

' =========================================================================
'
'   File...... Pygmy_3x-v3.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 19 FEB 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = out; no ULN
SYMBOL  Smellovision    = PIN6
SYMBOL  Dart3           = PIN5
SYMBOL  Pygmy3          = PIN4
SYMBOL  Dart2           = PIN3
SYMBOL  Pygmy2          = PIN2
SYMBOL  Dart1           = PIN1
SYMBOL  Pygmy1          = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  BlowOn          = 150                   ' blow valve on-time
SYMBOL  BlowOff         = 75                    ' blow valve off-time

SYMBOL  StinkTime       = 5000


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

SYMBOL  playList        = B0                    ' sequences played
SYMBOL  mask            = B1                    ' used with play list
SYMBOL  check           = B2

SYMBOL  nDarts1         = B3                    ' dart counters
SYMBOL  nDarts2         = B4
SYMBOL  nDarts3         = B5
SYMBOL  pntr            = B6                    ' table pointer

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %01111111                              ' make P0-P6 outputs

  timer = 0


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

Main:
  RANDOM lottery                                ' stir the pot
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 250 THEN Main                      ' wait for 0.25 sec input

Pre_Delay:
  PAUSE 2000

Select_Sequence:
  RANDOM lottery
  pntr = lottery // 6                           ' select, 0..5
  READ pntr, mask                               ' convert to bit mask
  check = playList & mask                       ' test play list
  IF check <> 0 THEN Select_Sequence            ' try again if played
    playList = playList | mask                  ' mark this selection
    pntr = pntr * 3 + 8                         ' point to table

Attack:
  READ pntr, PINS                               ' pop a pygmy
  pntr = pntr + 1                               ' point to next
  RANDOM lottery
  timer = lottery // 751 + 250                  ' timer = 250 to 1000
  PAUSE timer                                   ' short delay
  check = PINS & %00010101                      ' scan pygmy pins
  IF check <> %00010101 THEN Attack             ' wait for all to pop
    timer = 3000 - timer
    PAUSE timer                                 ' let last pygmy pop

Load_Darts:
  RANDOM lottery
  nDarts1 = lottery // 3 + 1                    ' 1 to 3 darts
  RANDOM lottery
  nDarts2 = lottery // 3 + 1
  RANDOM lottery
  nDarts3 = lottery // 3 + 1

Shoot1:
  IF nDarts1 = 0 THEN Shoot2                    ' skip if out of darts
    Dart1 = IsOn                                ' shoot!
    nDarts1 = nDarts1 - 1                       ' update ammo count
    PAUSE 50

Shoot2:
  IF nDarts2 = 0 THEN Shoot3
    Dart2 = IsOn
    nDarts2 = nDarts2 - 1
    PAUSE 50

Shoot3:
  IF nDarts3 = 0 THEN Blow_Baby_Blow
    Dart3 = IsOn
    nDarts3 = nDarts3 - 1
    PAUSE 50

Blow_Baby_Blow:
  PAUSE BlowOn                                  ' hold for air on-time

Breathe1:
  Dart1 = IsOff                                 ' dart off
  PAUSE 50
  IF nDarts1 > 0 THEN Breathe2                  ' ammo left?
    Pygmy1 = IsDown                             '  no, hide pygmy

Breathe2:
  Dart2 = IsOff
  PAUSE 50
  IF nDarts2 > 0 THEN Breathe3
    Pygmy2 = IsDown

Breathe3:
  Dart3 = IsOff
  PAUSE 50
  IF nDarts3 > 0 THEN Deep_Breath
    Pygmy3 = IsDown

Deep_Breath:
  PAUSE BlowOff

Check_Pygmies:
  check = PINS & %00010101                      ' scan pygmy pins
  IF check > %000000 THEN Shoot1                ' if any standing, continue

Stink_It_Up:
  Smellovision = IsOn
  PAUSE StinkTime
  Smellovision = IsOff

  IF playList <> %00111111 THEN Reset           ' all played?
    playList = %00000000                        ' clear list if yes
    GOTO Reset


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


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


' -----[ User Data ]-------------------------------------------------------

Bit_Mask:
  EEPROM (%00000001)
  EEPROM (%00000010)
  EEPROM (%00000100)
  EEPROM (%00001000)
  EEPROM (%00010000)
  EEPROM (%00100000)
  EEPROM (%01000000)
  EEPROM (%10000000)

Pop_Sequences:
  EEPROM (%000001, %000101, %010101)            ' 1, 2, 3
  EEPROM (%000001, %010001, %010101)            ' 1, 3, 2
  EEPROM (%000100, %000101, %010101)            ' 2, 1, 3
  EEPROM (%000100, %010100, %010101)            ' 2, 3, 1
  EEPROM (%010000, %010001, %010101)            ' 3, 1, 2
  EEPROM (%010000, %010100, %010101)            ' 3, 2, 1




Jon McPhalen
EFX-TEK Hollywood Office

Eric

Hey Jon.....I just ordered a bunch of Prop 2 controllers I really want to get things as random as possible...I guess this thread should move to the prop category now?


Thank You,

Eric

JonnyMac

Restate the "problem" in the Prop-2 forum... and then give me a bit of time as it's not a trivial program.
Jon McPhalen
EFX-TEK Hollywood Office