November 23, 2024, 12:39:14 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


coffin or monster in box

Started by rott, October 21, 2011, 08:57:02 AM

Previous topic - Next topic

JackMan

Not sure if you are still interested but here's an updated version of your program that starts the fog blast at the same time as the lid rattle instead of 3 seconds before. The fog blast duration is adjustable by changing the FOG_TIME value under Constants.


'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN   P.6 W/R to COM/NO of remote
SYMBOL  Fogger          = 2                     ' V+/OUT2 to 12v relay coil for fogger control
SYMBOL  Audio           = 1                     ' V+/OUT1 to 12v trigger inputs of Audio Player
SYMBOL  Valve           = 0                     ' solenoid on V+/OUT0

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

SYMBOL  PULSE_MIN       =   75                  ' min valve delay
SYMBOL  PULSE_MAX       =  250                  ' max valve delay
SYMBOL  RATTLE_TIME     = 20000                 ' 20 second rattle duration (change to suit)
SYMBOL  FOG_TIME        = 3000                  ' 3 seconds fog duration (change to suit)

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

SYMBOL  fog_timer       = W2                    ' for fog time
SYMBOL  delay           = W3                    ' allow long delays (>255)
SYMBOL  timer           = W4                    ' for debounce/rattle time
SYMBOL  lottery         = W5                    ' random #

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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  RANDOM lottery
  PAUSE 5                                       ' scan delay
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Check_Trigger             ' wait for 0.2 sec input

  timer = 0
  fog_timer = 0

  HIGH Audio                                    ' start audio player/relays
  PAUSE 250                                     ' 1/4 second pulse
  LOW Audio
  HIGH Fogger                                   ' start fogger

Rattle_Lid:
  RANDOM lottery
  delay = PULSE_MAX - PULSE_MIN + 1             ' calculate span for //
  delay = lottery // delay + PULSE_MIN          ' caculate delay
  TOGGLE Valve
  PAUSE delay
  timer = timer + delay                         ' update rattle timer
  fog_timer = fog_timer + delay                 ' update fog timer
  IF fog_timer < FOG_TIME THEN Rattle_Lid
  LOW Fogger
  IF timer < RATTLE_TIME THEN Rattle_Lid

  GOTO Reset