November 23, 2024, 05:43:05 PM

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.


need shake and bake code

Started by Nitemare, October 14, 2010, 10:24:20 AM

Previous topic - Next topic

Nitemare

I am very very green when it comes to working with prop 1. I am trying to learn but running out of time. I open my haunted house this Friday ( tomorrow) and need a code for my electric chair guy. I have made a shake and bake guy with two pneumatics one in the back and one in the butt to make him shake
(http://www.youtube.com/watch?v=w41pxso7IY8). I am using a foger and a red light to light the eyes. I am using a PIR sensor for the trigger. I can not get a code to work all that and give the trigger a 45 second cool down before resetting my prop off. Does any one have that code ??? I just want him to work on the PIR Sensor trigger for my haunt this weekend.. please help

JonnyMac

October 14, 2010, 11:08:16 AM #1 Last Edit: October 14, 2010, 12:04:12 PM by JonnyMac
One of the nightmares (pun intended) about writing code remotely is getting all of the information.  Many of us have written electric chair code and all programs have unique sequences.  In addition to the shaking you have a light and a fogger.  When should they come on in relation to the shaking?  How long should the shaking last?

Details are important.  And, please... don't make anyone watch a video and reverse engineer the process.  You will get code that does what you want when you take a second to spell out exactly what you want!  ;D

I've got a program started, just waiting for your details.
Jon McPhalen
EFX-TEK Hollywood Office

Nitemare

Thanks for a fast reply and once again I am very new. I would like the back manifold to jerk for 10 seconds very violently . The bottom manifold to shake him for 8 second, 1 second delay from the shaking at the bottom from when the  back jerking starts and a 1 second delay before the back jerking ends .I only posted the video because I don't know how to describe that action besides seeing it. I would like the fog to start 2 seconds into the start of the back jerking and last 5 seconds. the light in the eyes to start when the back starts jerking. there needs to be a 60 second delay before it is ready to be triggered by the PIR sensor again.  thank you once again.

JonnyMac

Keep in mind that a program is a list of instructions so providing your behavior in a list is usually a little easier to follow than one, bunched-up paragraph.

I think this will do what you want.  The outputs on my Trainer board are behaving as they should.  Do keep in mind that the Light and Fogger must be controlled through relays.

' =========================================================================
'
'   File......  Shake_n_Bake.bs1
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Fogger          = PIN3                  ' relay to fogger remote
SYMBOL  Light           = PIN2                  ' relay to light

SYMBOL  Seat            = PIN1
SYMBOL  Back            = PIN0


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

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


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

SYMBOL  valves          = B2
SYMBOL  last            = B3

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


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

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

 PAUSE 60000                                   ' 60s warm-up/reset 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

 timer = 0                                     ' reset timer
 Light = IsOn

 ' Shake back only for ~1 second

Shake1:
 RANDOM lottery
 Back = IsOn - Back                            ' toggle output
 delay = lottery // 151 + 100                  ' create delay
 PAUSE delay
 timer = timer + delay
 IF timer < 1000 THEN Shake1


 ' Shake back and seat 8 seconds
 ' -- control fog (on @2s, off at @7s)

Shake2:
 RANDOM lottery
 valves = lottery & %00000011                  ' isolate two bits
 IF valves = last THEN Shake2                  ' force change
   last = valves
 PINS = PINS & %11111100 | valves              ' update valve outputs
 RANDOM lottery
 delay = lottery // 151 + 100                  ' create delay
 PAUSE delay
 timer = timer + delay

Check_Fogger:
 IF timer < 2000 THEN Shake2                   ' pre  fogger?
 IF timer > 7000 THEN Fog_Off                  ' post fogger?

Fog_On:
 Fogger = IsOn
 GOTO Shake2

Fog_Off:
 Fogger = IsOff

Check_Timer:
 IF timer < 9000 THEN Shake2


 Seat = IsOff                                  ' make sure seat is off

Shake3:
 RANDOM lottery
 Back = IsOn - Back                            ' toggle output
 delay = lottery // 151 + 100                  ' create delay
 PAUSE delay
 timer = timer + delay
 IF timer < 10000 THEN Shake3

 GOTO Reset


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


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


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


Jon McPhalen
EFX-TEK Hollywood Office

Nitemare

Thank you so much. I am going to take this year after my haunt to understand how to write and understand the code. Love these Prop 1 controls!!!! Can't wait to see what all I can make now.