November 21, 2024, 03:51:44 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Random Timing Interval

Started by alphachi, September 16, 2015, 04:11:58 PM

Previous topic - Next topic

alphachi

Hello, I am trying to set the interval between scares randomly from 100 to 210 seconds. Does the code below look accurate for my goal?
' =========================================================================
'
'   File....... FrontDoorTV.BS1
'   Purpose.... FrontDoorTV
'   Author..... Allan
'   E-mail.....
'   Started.... September 16 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  Trigger         = PIN7                  '
SYMBOL  unused          = PIN6                  '
SYMBOL  unused2         = PIN5                  '
SYMBOL  Aircannon       = PIN4                  '
SYMBOL  Blood           = PIN3                  '
SYMBOL  Hand            = PIN2                  '
SYMBOL  Wolf            = PIN1                  '
SYMBOL  Witch           = PIN0                  '


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPEN         = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1

SYMBOL  IS_DOWN         = 0
SYMBOL  IS_UP           = 1

SYMBOL  StartDelay_MIN    = 100000                 ' min delay
SYMBOL  StartDelay_MAX    = 210000                ' max delay


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

SYMBOL  lottery        = W5                    ' random #
SYMBOL  delay          = W3                    ' allow long delays (>255)
SYMBOL  timer          = W4                    ' for event time

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

Power_Up:
  lottery = 1031                                ' seed random #

Reset:
'         76543210
  DIRS = %01111111                              ' P7 ins, P6-P0 outs
  PINS = %00000000                              ' all outputs off

  PAUSE 1000                                    ' pir warm-up / re-trigger
' -----[ Program Code ]----------------------------------------------------

Main:
  GOSUB ActionDelay
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000

  GOSUB ActionDelay
  Witch = IS_ON
  PAUSE 1000
  Witch = IS_OFF
  PAUSE 10000

  GOSUB ActionDelay
  Hand = IS_ON
  PAUSE 1600
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Hand = IS_OFF
  PAUSE 10000

  GOSUB ActionDelay
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000

  GOSUB ActionDelay
  Wolf = IS_ON
  PAUSE 750
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Wolf = IS_OFF
  PAUSE 10000

  GOTO Reset

ActionDelay:
  RANDOM lottery                               ' re-stir
  delay = 0
  delay = StartDelay_MAX - StartDelay_MIN + 1   ' get span
  delay = lottery // delay + 1                ' calc start delay
  delay = delay * 1000
  PAUSE delay
  RETURN

JackMan

BS1 won't accept any value greater than 65535. Your values for StartDelay are too large. Give this a try, I haven't tested it but it should work.


'   File....... FrontDoorTV.BS1
'   Purpose.... FrontDoorTV
'   Author..... Allan
'   E-mail.....
'   Started.... September 16 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  Trigger         = PIN7                  '
SYMBOL  unused          = PIN6                  '
SYMBOL  unused2         = PIN5                  '
SYMBOL  Aircannon       = PIN4                  '
SYMBOL  Blood           = PIN3                  '
SYMBOL  Hand            = PIN2                  '
SYMBOL  Wolf            = PIN1                  '
SYMBOL  Witch           = PIN0                  '


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPEN         = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1

SYMBOL  IS_DOWN         = 0
SYMBOL  IS_UP           = 1

SYMBOL  StartDelay_MIN    = 25000                ' min delay
SYMBOL  StartDelay_MAX    = 52500                ' max delay


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

SYMBOL  lottery        = W5                    ' random #
SYMBOL  delay          = W3                    ' allow long delays (>255)
SYMBOL  timer          = W4                    ' for event time

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

Power_Up:
  lottery = 1031                                ' seed random #

Reset:
'         76543210
  DIRS = %01111111                              ' P7 ins, P6-P0 outs
  PINS = %00000000                              ' all outputs off

  PAUSE 1000                                    ' pir warm-up / re-trigger
' -----[ Program Code ]----------------------------------------------------

Main:
  GOSUB ActionDelay
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000

  GOSUB ActionDelay
  Witch = IS_ON
  PAUSE 1000
  Witch = IS_OFF
  PAUSE 10000

  GOSUB ActionDelay
  Hand = IS_ON
  PAUSE 1600
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Hand = IS_OFF
  PAUSE 10000

  GOSUB ActionDelay
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000

  GOSUB ActionDelay
  Wolf = IS_ON
  PAUSE 750
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Wolf = IS_OFF
  PAUSE 10000

  GOTO Reset

ActionDelay:
  RANDOM lottery                                ' re-stir
  delay = StartDelay_MAX - StartDelay_MIN + 1   ' get span
  delay = lottery // delay + StartDelay_MIN     ' calc start delay
  PAUSE delay
  PAUSE delay
  PAUSE delay
  PAUSE delay
  RETURN

JonnyMac

September 16, 2015, 11:39:54 PM #2 Last Edit: September 17, 2015, 10:20:43 AM by JonnyMac
As Jack pointed out, with 16-bit values you cannot have a number larger than 65535. Start by changing your limit definitions:

SYMBOL  StartDelay_Min  = 100                   ' min delay
SYMBOL  StartDelay_Max  = 210                   ' max delay


Next, change the Action_Delay subroutine to work in seconds -- like this:

Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = StartDelay_Max - StartDelay_Min + 1   ' get span
  delay = lottery // delay + StartDelay_Min     ' randomized seconds

Delay_1S:
  PAUSE 1000                                    ' delay 1 second
  delay = delay - 1                             ' decrement
  IF delay > 0 THEN Delay_1S                    ' repeat if not done
    RETURN



Note, too, that this strategy gives you a 2-for-1 subroutine. With Delay_1S embedded in and the exit point for Action_Delay, you can call it if needed. Let's say you want to do a fixed delay in the program that is greater than 65 seconds (max value with PAUSE). Just put that value into delay and do a GOSUB Delay_1S.

With a very small processor like the Prop-1 we sometimes design these kinds of tricks to get the most out of a small code base.
Jon McPhalen
EFX-TEK Hollywood Office

Jeff Haas

Hi, I'm going through this code to understand how it calculates a random delay, within a certain period (100 - 210 seconds).

One thing I don't understand is one line in this section:

Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = StartDelay_Max - StartDelay_Min + 1   ' get span
  delay = lottery // delay + StartDelay_Min          ' randomized seconds


Why do you need to get the span of the StartDelay_Min to StartDelay_Max?  That number is always 111, and it gets changed in the next line when the seconds are randomized, and the new value is used by the loop in Delay_1S.

Jeff Haas

Ok, I just got it...that line allows you to change the min and max values of the delay at the top in the constants, and have the rest of the code calculate the other values needed.

Typical...get up, walk away from the computer, and it hits me.  It's not like I haven't used that technique before! ;D

JackMan

Go with Jon's program. Mine pretty much yields a 100 second delay each time due to the high value of StartDelay_Min.
With that large value in place the modulus operator (//) doesn't work well for this application.

JonnyMac

Quote from: Jeff Haas on September 17, 2015, 02:16:59 AM
Ok, I just got it...that line allows you to change the min and max values of the delay at the top in the constants, and have the rest of the code calculate the other values needed.

Typical...get up, walk away from the computer, and it hits me.  It's not like I haven't used that technique before! ;D

I do that all the time: when I'm stuck, I either change to a new project for a while or walk away from my computer. I have been taking 10-minute walks every hour to clear my head and find that about half-way around the block I solve the problem that was aggravating me.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

September 17, 2015, 12:32:57 PM #7 Last Edit: September 17, 2015, 12:35:13 PM by JonnyMac
Since we're getting into the swing of the Halloween season I thought I'd show you another variation on your program. Instead of running your props in the same order with random time in between, this randomizes the order, too.

Trick: RANDOM is not truly random, is pseudo-random. What that means is with the same seed, you will get the same sequence. The way we an defeat this is by stirring the random # until there is some kind of external input. For this program you need to add a button onto P7 and put the SETUP jumper in the down position. Connect the button between the P7.W (white/signal) and P7.R (red/5v) pins. The program will still the random # until you press the button -- by doing this you add an external element and get more randomness.

The code also uses one of my processes for playing all sections without repeating any before all have played, and not playing the same section back-to-back.

' =========================================================================
'
'   File....... FrontDoorTV_v2.BS1
'   Purpose.... FrontDoorTV
'   Author..... Allan
'   E-mail.....
'   Started.... 17 SEP 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  Trigger         = PIN7                  ' button input to start
SYMBOL  NC06            = PIN6
SYMBOL  NC05            = PIN5
SYMBOL  Aircannon       = PIN4
SYMBOL  Blood           = PIN3
SYMBOL  Hand            = PIN2
SYMBOL  Wolf            = PIN1
SYMBOL  Witch           = PIN0


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPENED       = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1

SYMBOL  IS_DOWN         = 0
SYMBOL  IS_UP           = 1

SYMBOL  DELAY_MIN       = 100                   ' min delay
SYMBOL  DELAY_MAX       = 210                   ' max delay


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

SYMBOL  action          = B2
SYMBOL  last            = B3
SYMBOL  mask            = B4
SYMBOL  played          = B5
SYMBOL  check           = B6

SYMBOL  delay           = W4                    ' allow long delays (>255)
SYMBOL  lottery         = W5                    ' random #


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

Reset:
'         76543210
  DIRS = %01111111                              ' P7 ins, P6-P0 outs
  PINS = %00000000                              ' all outputs off

  last = -1
  lottery = 1031                                ' pre-seed random #

Stir_Lotto:
  RANDOM lottery
  IF Trigger = IS_OFF THEN Stir_Lotto           ' press P7 to start


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

Main:
  GOSUB Action_Delay                            ' variable delay

New_Action:
  RANDOM lottery                                ' re-stir
  action = lottery // 4                         ' 0..3
  IF action = last THEN New_Action              ' if last, try again

  READ action, mask                             ' convert to bit mask
  check = mask & played                         ' check to see if played
  IF check <> 0 THEN New_Action                 ' if played, try again

  last = action                                 ' mark for next cycle
  played = played | mask
  IF played <> %00001111 THEN Run_Action        ' if list not full, go!
    played = %00000000                          '  reset list 1st


Run_Action:
  BRANCH action, (Run_Blood, Run_Witch, Run_Hand, Run_Wolf)
  GOTO Main


Run_Blood:
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000
  GOTO Main


Run_Witch:
  Witch = IS_ON
  PAUSE 1000
  Witch = IS_OFF
  PAUSE 10000
  GOTO Main


Run_Hand:
  Hand = IS_ON
  PAUSE 1600
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Hand = IS_OFF
  PAUSE 10000
  GOTO Main


Run_Wolf:
  Wolf = IS_ON
  PAUSE 750
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Wolf = IS_OFF
  PAUSE 10000
  GOTO Main


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

Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = DELAY_MAX - DELAY_MIN + 1             ' get span
  delay = lottery // delay + DELAY_MIN          ' randomized seconds

Delay_1S:
  PAUSE 1000                                    ' delay 1 second
  delay = delay - 1                             ' decrement
  IF delay > 0 THEN Delay_1S                    ' repeat if not done
    RETURN


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

Bit_Masks:
  EEPROM (%00000001, %00000010, %00000100, %00001000)

Jon McPhalen
EFX-TEK Hollywood Office

alphachi

Perfect, this is exactly what I needed:
Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = DELAY_MAX - DELAY_MIN + 1             ' get span
  delay = lottery // delay + DELAY_MIN          ' randomized seconds

Delay_1S:
  PAUSE 1000                                    ' delay 1 second
  delay = delay - 1                             ' decrement
  IF delay > 0 THEN Delay_1S                    ' repeat if not done
    RETURN

Quote from: JonnyMac on September 17, 2015, 12:32:57 PM
Since we're getting into the swing of the Halloween season I thought I'd show you another variation on your program. Instead of running your props in the same order with random time in between, this randomizes the order, too.

Trick: RANDOM is not truly random, is pseudo-random. What that means is with the same seed, you will get the same sequence. The way we an defeat this is by stirring the random # until there is some kind of external input. For this program you need to add a button onto P7 and put the SETUP jumper in the down position. Connect the button between the P7.W (white/signal) and P7.R (red/5v) pins. The program will still the random # until you press the button -- by doing this you add an external element and get more randomness.

The code also uses one of my processes for playing all sections without repeating any before all have played, and not playing the same section back-to-back.

' =========================================================================
'
'   File....... FrontDoorTV_v2.BS1
'   Purpose.... FrontDoorTV
'   Author..... Allan
'   E-mail.....
'   Started.... 17 SEP 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  Trigger         = PIN7                  ' button input to start
SYMBOL  NC06            = PIN6
SYMBOL  NC05            = PIN5
SYMBOL  Aircannon       = PIN4
SYMBOL  Blood           = PIN3
SYMBOL  Hand            = PIN2
SYMBOL  Wolf            = PIN1
SYMBOL  Witch           = PIN0


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPENED       = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1

SYMBOL  IS_DOWN         = 0
SYMBOL  IS_UP           = 1

SYMBOL  DELAY_MIN       = 100                   ' min delay
SYMBOL  DELAY_MAX       = 210                   ' max delay


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

SYMBOL  action          = B2
SYMBOL  last            = B3
SYMBOL  mask            = B4
SYMBOL  played          = B5
SYMBOL  check           = B6

SYMBOL  delay           = W4                    ' allow long delays (>255)
SYMBOL  lottery         = W5                    ' random #


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

Reset:
'         76543210
  DIRS = %01111111                              ' P7 ins, P6-P0 outs
  PINS = %00000000                              ' all outputs off

  last = -1
  lottery = 1031                                ' pre-seed random #

Stir_Lotto:
  RANDOM lottery
  IF Trigger = IS_OFF THEN Stir_Lotto           ' press P7 to start


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

Main:
  GOSUB Action_Delay                            ' variable delay

New_Action:
  RANDOM lottery                                ' re-stir
  action = lottery // 4                         ' 0..3
  IF action = last THEN New_Action              ' if last, try again

  READ action, mask                             ' convert to bit mask
  check = mask & played                         ' check to see if played
  IF check <> 0 THEN New_Action                 ' if played, try again

  last = action                                 ' mark for next cycle
  played = played | mask
  IF played <> %00001111 THEN Run_Action        ' if list not full, go!
    played = %00000000                          '  reset list 1st


Run_Action:
  BRANCH action, (Run_Blood, Run_Witch, Run_Hand, Run_Wolf)
  GOTO Main


Run_Blood:
  Blood = IS_ON
  PAUSE 1000
  Blood = IS_OFF
  PAUSE 15000
  GOTO Main


Run_Witch:
  Witch = IS_ON
  PAUSE 1000
  Witch = IS_OFF
  PAUSE 10000
  GOTO Main


Run_Hand:
  Hand = IS_ON
  PAUSE 1600
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Hand = IS_OFF
  PAUSE 10000
  GOTO Main


Run_Wolf:
  Wolf = IS_ON
  PAUSE 750
  AirCannon = IS_ON
  PAUSE 400
  AirCannon = IS_OFF
  Wolf = IS_OFF
  PAUSE 10000
  GOTO Main


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

Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = DELAY_MAX - DELAY_MIN + 1             ' get span
  delay = lottery // delay + DELAY_MIN          ' randomized seconds

Delay_1S:
  PAUSE 1000                                    ' delay 1 second
  delay = delay - 1                             ' decrement
  IF delay > 0 THEN Delay_1S                    ' repeat if not done
    RETURN


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

Bit_Masks:
  EEPROM (%00000001, %00000010, %00000100, %00001000)


wdgoof

I have "borrowed" this code for my prop and modified it for my own symbols (and lowered the times time for testing).  But when I try to run it, it doesn't seem to trigger or run.  Similar to the original post, I have 4 "events" that I want to each run in random order each time the trigger is activated.  Eventually I will put this on a motion sensor, but for now it is on a button trigger.
Can you please help me understand why this is not triggering?

Thank You
Wayne Dvorak

JonnyMac

September 24, 2015, 04:10:40 PM #10 Last Edit: September 26, 2015, 11:32:14 AM by JonnyMac
I [temporarily] replaced the code in Action_Delay with a fixed 1-second PAUSE and it worked fine (I'm using DEBUG to see that each section runs).

Your update of that subroutine may be causing problems. You could subtract 10 from a value and get an underflow which would create a very long -- seemingly infinite -- delay.

Here's an update of your program that may help you get to where you want to go (Yogi Berra said, "If you don't know where you're going you may end up somewhere else!"). Since you weren't very specific, I made a leap that after getting a trigger from the PIR you want to run your four elements in random order, with a random delay between them. When all have run, we wait for another trigger. If you just want the props to run all night long, there is no reason for a PIR.

Note that I've added DEBUG statements so that I can see the program operating. I also changed PAUSE 1000 in Action_Delay to PAUSE 1 to speed things along. If you want to use different delays, change the DELAY_MIN and DELAY_MAX constants at the top of the program (it's what's they're for); don't rewrite the delay code.

Note: Fixed errant DEBUG label on 26 SEP 2015. Also restored normal timing in Action_Delay

' =========================================================================
'
'   File....... Restles stones.BS1
'   Purpose.... Animate restless stones
'   Author..... Allan
'   E-mail.....
'   Started.... 23 SEP 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  Trigger         = PIN7                  ' button input to start
SYMBOL  STONE1          = PIN6
SYMBOL  STONE2          = PIN5
SYMBOL  EYES1           = PIN4
SYMBOL  EYES2           = PIN3
'SYMBOL  Hand           = PIN2
'SYMBOL  Wolf           = PIN1
'SYMBOL  Witch          = PIN0


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPENED       = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1

SYMBOL  IS_DOWN         = 0
SYMBOL  IS_UP           = 1

SYMBOL  DELAY_MIN       = 100                   ' min delay
SYMBOL  DELAY_MAX       = 210                   ' max delay


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

SYMBOL  timer           = B0

SYMBOL  action          = B2
SYMBOL  last            = B3
SYMBOL  mask            = B4
SYMBOL  played          = B5
SYMBOL  check           = B6

SYMBOL  delay           = W4                    ' allow long delays (>255)
SYMBOL  lottery         = W5                    ' random #


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

Reset:
'         76543210
  DIRS = %01111111                              ' P7 ins, P6-P0 outs
  PINS = %00000000                              ' all outputs off

  last = -1
  lottery = 1031                                ' pre-seed random #

  DEBUG "Waiting for trigger", CR

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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 10                                      ' scan delay
  IF Trigger = IS_OFF THEN Main                 ' check trigger input
    timer = timer + 10                          ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

Run_Delay:
  DEBUG "Running action delay", CR
  GOSUB Action_Delay                            ' variable delay

New_Action:
  RANDOM lottery                                ' re-stir
  action = lottery // 4                         ' 0..3
  IF action = last THEN New_Action              ' if last, try again

  READ action, mask                             ' convert to bit mask
  check = mask & played                         ' check to see if played
  IF check <> 0 THEN New_Action                 ' if played, try again

Run_Action:
  BRANCH action, (Run_Stone1, Run_Stone2, Run_Eyes1, Run_Eyes2)
  GOTO Reset


Run_Stone1:
  DEBUG "Stone 1", CR
  STONE1 = IS_ON
  EYES1 = IS_ON
  PAUSE 3000
  STONE1 = IS_OFF
  EYES1 = IS_OFF
  PAUSE 1500
  GOTO Finish_Action


Run_Stone2:
  DEBUG "Stone 2", CR
  STONE2 = IS_ON
  EYES2 = IS_ON
  PAUSE 3000
  STONE2 = IS_OFF
  EYES2 = IS_OFF
  PAUSE 1000
  GOTO Finish_Action


Run_Eyes1:
  DEBUG "Eyes 1", CR
  EYES1 = IS_ON
  PAUSE 250
  EYES1 = IS_OFF
  PAUSE 1000
  GOTO Finish_Action


Run_Eyes2:
  DEBUG "Eyes 2", CR
  EYES2 = IS_ON
  PAUSE 750
  EYES2 = IS_OFF
  PAUSE 1000
  GOTO Finish_Action


Finish_Action:
  last = action                                 ' mark for next cycle
  played = played | mask
  IF played <> %00001111 THEN Run_Delay         ' if list not full, go!
    played = %00000000                          '  reset list 1st
    GOTO Reset                                  '  wait for new trigger


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

Action_Delay:
  RANDOM lottery                                ' re-stir
  delay = DELAY_MAX - DELAY_MIN + 1             ' get span
  delay = lottery // delay + DELAY_MIN          ' randomized seconds

  DEBUG delay, CR

Delay_1S:
  PAUSE 1000                                    ' delay 1 second
  delay = delay - 1
  IF delay > 0 THEN Delay_1S                    ' repeat if not done
    RETURN


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

Bit_Masks:
  EEPROM  (%00000001, %00000010, %00000100, %00001000)
Jon McPhalen
EFX-TEK Hollywood Office

wdgoof

Thank you very much, this is indeed what I wanted.  SO not only are you awesome coders, and offer fantastic support, apparently you are mind readers as well.

I cant thank you enough as we head into crunch time for helping me get this code straightened out.

Jeff Haas

There's a small typo in this:

Run_Stone2:
  DEBUG "Stone 1", CR


"Stone 1" should be "Stone 2" in this section.

JonnyMac

Whoops, copy-and-paste error on my part. Thanks for the catch, Jeff.
Jon McPhalen
EFX-TEK Hollywood Office