November 22, 2024, 06:44:02 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 trigger

Started by tj, September 21, 2008, 04:13:18 PM

Previous topic - Next topic

tj

hey jon got a mat switch that i want to use on prop 1. i want it to trigger on a random person, maybe from 5th to 12th person
then toggle pins 0 and 1 on and off randomly for 15 secs quickly. i think i can add in from that

JonnyMac

September 21, 2008, 04:35:42 PM #1 Last Edit: September 21, 2008, 09:32:02 PM by JonnyMac
Give this a try -- it's a quickie as I'm heading out to a show.  It does compile, so we can adjust for "real life" once things are hooked up and running.

[Edit] After an entertaining afternoon at the theater I am not relaxed and able to think more clearly.  Note below that I've added a little code that waits for all but the last victim to step off the mat.

' =========================================================================
'
'   File...... Random_Trigger.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 21 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  victim          = B2
SYMBOL  counter         = B3

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000011                              ' make P0-P1 outputs

  victim = lottery // 8 + 5                     ' 5 to 12
  counter = 0


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

Main:
  timer = 0                                     ' reset timer

Force_Release:
  IF Trigger = IsOn THEN Force_Release


Check_Trigger:
  RANDOM lottery
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.2 sec input
    PAUSE 100                                   ' let victim step off
    counter = counter + 1
    IF counter < victim THEN Main               ' wait for victim count

  timer = 0

Thrash:
  RANDOM lottery
  PINS = lottery & %00000011                    ' update P0 and P1
  PAUSE 100
  timer = timer + 100
  IF timer < 15000 THEN Thrash

  GOTO Reset


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


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


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


Jon McPhalen
EFX-TEK Hollywood Office

tj

thanks jon, that will give me a start, will work timing out later

tj

thanks for the reply and update, i like the release. after halloween i have more questions