November 22, 2024, 10:33:22 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.


Prop 1, solenoid, LED lights, PIR

Started by gatesofterror, February 11, 2009, 06:09:51 PM

Previous topic - Next topic

gatesofterror

I've been looking around and haven't seen anything quite like this.
While finishing the large prop I have started a smaller hopefully less complicated prop. I believe all I need is a prop 1 to make this work. I want a 12volt LED light (Yellow) to be on at all times except when the prop trips.

1- Yellow LED 12v light is on
2- PIR activates
    Yellow LED goes out
    12 volt 400mA solenoid stays on 1 sec.
    2 12volt LEDs come on 1 sec.
    solenoid and 2 LEDs come on and go off together.
3- Yellow LED comes back on waiting for next cycle.
4- Need 20 second delay before the prop can recycle.
Thank you in advance.
Jim

JonnyMac

This is REALLY easy -- using the PINS register we can update all the outputs with one line of code.

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 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  Solenoid        = PIN2                  ' on OUT2
SYMBOL  Leds            = PIN1                  ' on OUT1
SYMBOL  Yellow          = PIN0                  ' on OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000001                              ' yellow on
  DIRS = %00000111                              ' set outputs

  PAUSE 20000                                   ' PIR warm-up/delay


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

Main:
  timer = 0                                     ' reset timer

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

  PINS = %00000110                              ' LEDs + Solenoid
  PAUSE 1000

  GOTO Reset


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


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

gatesofterror

Thank you Jon.
I'll let you know how it does when I get the large prop out of the way and this one set up. Already thinking what to start next. These props are a lot funner when I can set them up to do multiple things and add sound.

OH I forgot, is it possible to make the 2 lights flicker while the prop is activated?
Thanks
Jim

JonnyMac

February 12, 2009, 07:47:41 AM #3 Last Edit: February 12, 2009, 07:56:59 AM by JonnyMac
Many things are possible, Jim -- the devil is in the details.   What does "flicker" mean to you?  You'll find that as you start writing your own programs you must be very specific.

Here's an update with my idea of "flickering."

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 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  Solenoid        = PIN2                  ' on OUT2
SYMBOL  Leds            = PIN1                  ' on OUT1
SYMBOL  Yellow          = PIN0                  ' on OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

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


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

Reset:
  PINS = %00000001                              ' yellow on
  DIRS = %00000111                              ' set outputs

  PAUSE 20000                                   ' PIR warm-up/delay


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

Main:
  timer = 0                                     ' reset timer

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

  PINS = %00000110                              ' LEDs + Solenoid
  timer = 0

Flicker:
  RANDOM lottery
  delay = lottery // 51 + 25                    ' 25 to 75 ms
  PAUSE delay
  Leds = 1 - Leds                               ' flip LEDs state
  timer = timer + delay
  IF timer < 1000 THEN Flicker
    GOTO Reset


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


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