November 25, 2024, 03:12:50 AM

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.


Truck hood

Started by cmgjeep, August 20, 2009, 08:56:55 PM

Previous topic - Next topic

cmgjeep

I got a old truck hood out of a junkyard. With the help of the man J.Mac, I used a prop 1 controller and a pir sensor to starttle the dogs next door!
I wanted to trigger the hood for the lights to flash on and off 3 or 4 times and after the last flash (BLAST!!!!!) an air horn would go off. (120db)
This could almost make a person pee in their pants.
parts:
prop 1
pir
2 12v relays with +trigger
1 air horn kit for a car
1 dump truck hood with working lights

last and but not least
this forum



cmgjeep

the code (almost forgot)

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' 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  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Horn            = PIN1
SYMBOL  Lights          = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  idx             = B3


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

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


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

Main:
  timer = 0                                     ' reset timer

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

  FOR idx = 1 TO 4
    Lights = IsOn
    PAUSE 1500
    Lights = IsOff
    PAUSE 1000
  NEXT

  Horn = IsOn
  PAUSE 1000

  GOTO Reset                                    ' everything off


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


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


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

BigRez

Gonna post a video of it?  That'd be nice to see...   I should create something like that to scare the cats out of my planters!  ;D

cmgjeep

i had to change the trigger pause back to 5
i;m learning from my boo boos

cmgjeep

need to put a pause in the reset for trigger, so it will not get a false trigger on the power start up