November 26, 2024, 10:29:03 AM

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.


Need help with prop1, pir, and ap-8

Started by khamel, September 29, 2008, 02:40:30 PM

Previous topic - Next topic

khamel

Im in need of a program fairly quickly that includes the following.... once pir is triggered 2 sec pause...5 sec valve triggered with sound for 10 seconds then everything off for 20 seconds.... if anyone could help me asap it would be greatly appreciated...



Thanks

JonnyMac

I think this matches your explanation....

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Valve           = PIN0                  ' use OUT0


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = B2


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

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

  SEROUT Sio, Baud, ("!!!!!AP8", %00, "X")      ' stop if playing
  PAUSE 20000                                   ' PIR warm-up/show delay


' -----[ 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.2 sec input

  PAUSE 2000                                    ' hold 2 secs

  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' start audio (slot 0)

  Valve = IsOn
  PAUSE 5000

  Valve = IsOff
  PAUSE 5000

  GOTO Reset


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


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


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