November 22, 2024, 03:09:44 AM

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.


Controlling dual action cylinders on muliple ouputs randomly

Started by msmith78133, October 15, 2008, 12:58:57 PM

Previous topic - Next topic

msmith78133

I have two displays I am working on that will require random output on three different out puts. This will cause the lids on barrels to bang and make noise randomly from each other. They will be connected to a PIR device with a 10 second delay then the action starts for about 15 to 20 seconds.

The second would only need two outputs working pretty much that same as the first. There is a script already written on this forum for shaking cellar doors  for use with a prop1 controller that would work, just need it modified for the above set up.


JonnyMac

Since both applications are similar you can use this same program for both, just use two outputs on the second instead of all three

(Note: In the future, please use separate threads for each programming request).


' =========================================================================
'
'   File...... Barrel_Lids.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... 15 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Lid3            = PIN2
SYMBOL  Lid2            = PIN1
SYMBOL  Lid1            = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  idx             = B2

SYMBOL  timer           = W3
SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' set outputs


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  PAUSE 10000                                   ' 10 second delay
  timer = 0                                     ' reset timer

Shake_Em:
  FOR idx = 1 TO 3
    RANDOM lottery                              ' big stir
  NEXT
  PINS = lottery                                ' randomize lids
  delay = lottery // 151 + 100                  ' 0.1 to 0.25 seconds
  PAUSE delay
  timer = timer + delay
  IF timer < 20000 THEN Shake_Em                ' run for 20 seconds
    GOTO Reset


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


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


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