November 22, 2024, 11:31:38 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.


Creepy Coffin

Started by norm, October 26, 2010, 07:57:12 PM

Previous topic - Next topic

norm

Hi Jon,

I am having trouble with cut and past of a program you wrote for me (electric chair 2007) using random timings and the lottery.

My new prop is a creepy coffin:

PIR trips, coffin door move back and forth rapidly random timing via a pneumatic valve. I would like to be able to adjust the random timing. after 5 sec. everything shuts off.

Thanking you advance

Norm Peschel

JonnyMac

First... please stop calling me out; this dis-invites other very capable folks for helping you and is a violation of our forum guidelines.  Please, I hate reminding people to follow simple rules.

Second... don't talk about one thread in another; makes no sense and, again, is a violation of our rules.

Thanks for understanding -- here's your program:

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Lid             = PIN0


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

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

SYMBOL  ValveMin        = 100                   ' thrash timing range
SYMBOL  ValveMax        = 250

SYMBOL  ThrashTime      = 5000


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

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


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000001                              ' make P0 output

  PAUSE 30000                                   ' PIR warm-up


' -----[ 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

  timer = 0                                     ' restar thrash timer

Bump_And_Grind:
  RANDOM lottery
  Lid = IsOn - Lid                              ' toggle lid
  RANDOM lottery
  delay = ValveMax - ValveMin + 1               ' span
  delay = lottery // delay + ValveMin           ' calculate delay
  PAUSE delay                                   ' hold
  timer = timer + delay
  IF timer < ThrashTime THEN Bump_And_Grind
    GOTO Reset


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


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


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