November 21, 2024, 04:01:37 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Modify Program

Started by garner0070, September 17, 2015, 02:29:40 PM

Previous topic - Next topic

garner0070

I wanted to thank everyone for their help last year. The controllers worked great and all the props worked and the neighborhood loved them. I wanted to add a prop in conjunction with the program below. The program below is for a coffin lid and skeleton that pops out, then down then lid closed. I wanted to stay with this program just as is but once the lid closes add another output thru out put 3 to another valve to move another cylidner with a spider out and then reset the program.
I am terrible and writing code.

So after turn off output # 2 it would turn on out put #3, hold open for 8 seconds then turn off output #3 and then go to  step#8 (delay for 1 minute or so and resent for new victim).

I assume this is possible?

Old program below
' =========================================================================
'
'   File...... ez_coffin.bs1
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 06 OCT 2014
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


'  1. Output 0 on and hold on for 8 seconds
'  2. Turn off output 0
'  3. delay for 5 seconds
'  3. Turn output 1 on and hold on for 8 seconds
'  4.  Turn output 1 off
'  5. delay for 5 seconds
'  6. Turn output 2 on for 8 seconds
'  7. turn off output 2
  8. delay for 1 minute or so and reset for new victim.


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


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


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

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

SYMBOL  Lid_Close      = PIN2                  ' use V+/OUT2
SYMBOL  Skeleton       = PIN1                  ' use V+/OUT1
SYMBOL  Lid_Open       = PIN0                  ' use V+/OUT0


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

SYMBOL  IS_ON          = 1                     ' for active-high in/out
SYMBOL  IS_OFF         = 0

SYMBOL  IS_UP          = 1
SYMBOL  IS_DOWN        = 0

SYMBOL  PIR_HOLDOFF    = 60                    ' wait 60s before retrigger


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

SYMBOL  timer          = W5


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

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

  timer = PIR_HOLDOFF
  GOSUB Wait_Seconds


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

Main:
  timer = 0                                    ' reset timer

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

  Lid_Open = IS_ON
  PAUSE 8000

  Lid_Open = IS_OFF
  PAUSE 5000

  Skeleton = IS_UP
  PAUSE 8000

  Skeleton = IS_DOWN
  PAUSE 5000

  Lid_Close = IS_ON
  PAUSE 8000

  GOTO Reset                                   ' everything off



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

' Hold program # seconds in timer
' -- value in timer destroyed by routine

Wait_Seconds:
  IF timer = 0 THEN WS_Exit
    PAUSE 1000
    timer = timer - 1
    GOTO Wait_Seconds

WS_Exit:
  RETURN


JonnyMac

It's easy to add another output. Here you go:

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


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


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


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

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

SYMBOL  Spider          = PIN3                  ' use V+/OUT3
SYMBOL  Lid_Close       = PIN2                  ' use V+/OUT2
SYMBOL  Skeleton        = PIN1                  ' use V+/OUT1
SYMBOL  Lid_Open        = PIN0                  ' use V+/OUT0


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

SYMBOL  YES             = 1                     ' for active-high in/out
SYMBOL  NO              = 0

SYMBOL  IS_ON           = 1
SYMBOL  IS_OFF          = 0

SYMBOL  IS_UP           = 1
SYMBOL  IS_DOWN         = 0

SYMBOL  IS_OUT          = 1
SYMBOL  IS_IN           = 0

SYMBOL  PIR_HOLDOFF     = 60                    ' wait 60s before retrigger


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

SYMBOL  timer          = W5


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

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

  timer = PIR_HOLDOFF
  GOSUB Wait_Seconds


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

Main:
  timer = 0                                    ' reset timer

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

  Lid_Open = IS_ON
  PAUSE 8000

  Lid_Open = IS_OFF
  PAUSE 5000

  Skeleton = IS_UP
  PAUSE 8000

  Skeleton = IS_DOWN
  PAUSE 5000

  Lid_Close = IS_ON
  PAUSE 8000

  Spider = IS_OUT                               ' *
  PAUSE 8000                                    ' *

  Spider = IS_IN                                ' *

  GOTO Reset                                    ' everything off



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

' Hold program # seconds in timer
' -- value in timer destroyed by routine

Wait_Seconds:
  IF timer = 0 THEN WS_Exit
    PAUSE 1000
    timer = timer - 1
    GOTO Wait_Seconds

WS_Exit:
  RETURN



What I'm confused by is that it seems like the lid is closed before the skeleton pops up -- that's the way the code reads to me, anyway.
Jon McPhalen
EFX-TEK Hollywood Office

garner0070

Thank you for your help. I think the valve I have for the coffin lid is a 4-way 3 positon double solenoid valve. It did work last year very well. Just need to modify the to add this and then change the wait for victim time possibly.