November 23, 2024, 08:07:04 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.


Double Barrel Air Cannon

Started by painnbt, September 27, 2010, 06:26:27 PM

Previous topic - Next topic

JonnyMac

This one just "shoots."  Change the shooting speed by adjusting ShotTime (time valve is open) and ReloadTime (time valve is closed between shots).  As setup now, the gun fires 10 shots per second.  Lower numbers will make it shoot faster.  Adjust the ShotTime first to get the sound of the shot you want, then adjust reload time to set the fire rate.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$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  Shoot           = PIN2                  ' OUT2 = shooting valve
SYMBOL  Barrels         = PIN0                  ' OUT0 = position valve


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

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

SYMBOL  ShotTime        = 50                    ' valve open timing
SYMBOL  Reloadtime      = 50                    ' valve closed timing


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

SYMBOL  timer           = B2


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

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


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

Main:
  timer = 0                                     ' reset timer

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

Fire:
  Shoot = IsOn                                  ' fire
  PAUSE ShotTime                                ' allow "shot"
  Shoot = IsOff                                 ' close value
  PAUSE ReloadTime                              ' hold for "reload"

  IF Trigger = IsOn THEN Fire                   ' again if button pressed
    GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------



Jon McPhalen
EFX-TEK Hollywood Office