November 23, 2024, 01:40:13 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.


monster in a box program

Started by gwarboy2000, October 02, 2008, 05:51:35 PM

Previous topic - Next topic

gwarboy2000

October 02, 2008, 05:51:35 PM Last Edit: October 02, 2008, 06:03:17 PM by gwarboy2000
hi, im looking for just a simple monster-in-box program to use just a pir sensor and a pneumatic cylinder, to randomly open and close the box lid. im using a 12vdc solenoid

JonnyMac

There's at least a dozen such programs in these forums but this one's yours and I'll write it just for you.  But... we need some details:

1) How long does the bouncing last
2) Do you have any idea how long it takes your cylinder to extend/retract?
3) Any audio to go along with it.

Let me know and I'll whip up a program for you.
Jon McPhalen
EFX-TEK Hollywood Office

gwarboy2000

Quote from: JonnyMac on October 02, 2008, 10:37:27 PM
There's at least a dozen such programs in these forums but this one's yours and I'll write it just for you.  But... we need some details:

1) How long does the bouncing last
2) Do you have any idea how long it takes your cylinder to extend/retract?
3) Any audio to go along with it.

Let me know and I'll whip up a program for you.

1. id say like 6 sec would be good
2. umm good question. prolly about 1.5 sec or maybe a second
3. no audio this year.

JonnyMac

Okay, bad answer.  At the risk of sounding stern, programming is a very specific process and "prolly" (probably) doesn't cut it.  So... this is the best I can do.  Give it a try, it will probably work but could be better if we knew how the cylinder behaved.

' =========================================================================
'
'   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  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Cylinder        = PIN0                  ' use OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

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


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000001                              ' set outputs


' -----[ 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                                     ' reset for shaking

Shake_It:
  Cylinder = 1 - Cylinder                       ' toggle state
  RANDOM lottery
  delay = lottery // 401 + 100                  ' 0.10 to .50 seconds
  PAUSE delay
  timer = timer + delay
  IF timer < 6000 THEN Shake_It
    GOTO Reset


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


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


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


Jon McPhalen
EFX-TEK Hollywood Office