November 22, 2024, 08:40:36 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.


Skelerector

Started by redmond71, October 19, 2009, 09:59:20 PM

Previous topic - Next topic

redmond71

Hi
     The more I try to figure programming out the more confused I get.  I have a stack of prop 1 controllers that I would like to use for Halloween props.  I got the board of ed and got through that.  My problem is getting my feet wet I seem to get lost.  I have a skelerector prop that I would like to control with a prop1 using a PIR and also trigger sound as well as a spot light.  Can anybody point me in the right direction for getting started?
                         Thanks Mike

JonnyMac

Just tell us exactly what you want and we'll write a program for you.  When you see your specs converted to a real program things will start to come together.

Don't leave out any details -- we're good at coding, not so good at mind-reading.  ;D
Jon McPhalen
EFX-TEK Hollywood Office

redmond71

Hi Jon
           I hope I won't leave out anything you need to know!  I have a parallax PIR for the trigger a 24volt solenoid (if that is compatible?)  I want the prop to spring up and a spot light activate at the same time for about 5 secs.  Then have the prop half drop twice and then back to start position.  I am sure I am leaving out stuff you need to know but I am new to this

JonnyMac

You are... how long does it take to pop up (in seconds, could be a fraction) and go back down?
Jon McPhalen
EFX-TEK Hollywood Office

redmond71

LOL!   It springs up very very quickly. maybe a half a second??  Stay up for 5 seconds or so and head back down.

JonnyMac

Since you use terms like "about" and "very quickly" I'm taking a bit of artistic liberty -- hey, I live in Hollywood, we do that!  ;D

This follows the concept of your program but adds some randomness ("about").  The initial up time changes a little and the jumps are modified as well, with different timing each time through.  This will make your prop far more interesting, especially to those who trigger it more than once.

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


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Light           = PIN1                  ' use V+/OUT1
SYMBOL  Skeleton        = PIN0                  ' use V+/OUT0


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

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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  jumps           = B3
SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
 PINS = %00000000                              ' preset IOs
 DIRS = %00000011                              ' set output pins

 PAUSE 20000                                   ' pir warm-up/delay


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

 Skeleton = IsUp
 PAUSE 100                                     ' let skele get moving
 Light = IsOn

 RANDOM lottery
 delay = lottery // 2001 + 3000                ' 3.0 to 5.0 seconds
 PAUSE delay

 RANDOM lottery
 jumps = lottery // 3 + 2                      ' 2 to 4 jumps

Jump_Baby:
 RANDOM lottery
 delay = lottery // 351 + 150                  ' 0.15 to 0.50s
 Skeleton = IsDown                             ' lower
 PAUSE delay
 Skeleton = IsUp                               ' back up
 PAUSE delay                                   ' all the way
 RANDOM lottery
 delay = lottery // 251                        ' 0.0 to 0.25s hold
 PAUSE delay
 jumps = jumps - 1                             ' update jumps
 IF jumps = 0 THEN Goodbye                     ' done?
   GOTO Jump_Baby

Goodbye:
 PAUSE 1000                                    ' hold up for 1.0s
 GOTO Reset


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


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


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

redmond71

WOW!!!!
                  Thank you Maestro!  I will try that asap.  Do I enter everything that you wrote?  I am assuming that the definitions set the stage?   I know I must seem like a complete moron but I am a newbie nube but I hope to learn.
                  Thanks so much
       

JonnyMac

October 20, 2009, 12:20:54 PM #7 Last Edit: October 20, 2009, 12:23:16 PM by JonnyMac
If you manually enter everything I wrote then you are beyond help... newbies will spit on your image!  ;D

Copy-and-paste the program (just the blue stuff) from the forum right into the BASIC Stamp editor, save it, then download it into your Prop-1.
Jon McPhalen
EFX-TEK Hollywood Office