November 21, 2024, 11:38:03 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Prop1 with (2) RC-2

Started by Jeffery Hamilton, September 21, 2018, 01:02:07 PM

Previous topic - Next topic

Jeffery Hamilton


I need a program that will use a Prop1 and (2) RC-2 relays. This will be a stop light that will cycle through.
Stop Light timing, a figure I can change. Start with 30 seconds RED, 10 seconds YELLOW and 45 seconds GREEN,  I would like to connect a straight wire across terminal (P6 red and white wire) to loop. I would like to be able to change P6 to a inferred sensor if so desired I will use (3) GE Classic LED 45w replacement 6.5w R20 medium base (120vac)
Please add all 4 relays to program so I can use for future projects.

JonnyMac

Here you go. Note that you need three pins -- the RC-2 is not daisy-chained like the old RC-4; it's a very simple direct (plug-and-play) connection.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Red             = PIN2
SYMBOL  Yellow          = PIN1
SYMBOL  Green           = PIN0


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

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0


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

SYMBOL  timer           = B2


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

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000001                              ' green on
  DIRS = %00000111                              ' P2..P0 are outputs


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = IsOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 50 THEN Check_Trigger              ' check timer

  Green = IsOn                                  ' lamp on
  timer = 45                                    ' set timing
  GOSUB Delay_Seconds                           ' hold
  PINS = IsOff                                  ' all off

  Yellow = IsOn
  timer = 10
  GOSUB Delay_Seconds
  PINS = IsOff

  Red = IsOn
  timer = 30
  GOSUB Delay_Seconds
  PINS = IsOff

  GOTO Reset


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

' Put number of seconds to delay in "timer" before calling

Delay_Seconds:
  IF timer = 0 THEN PS_Exit
    PAUSE 1000
    timer = timer - 1
    GOTO Delay_Seconds

PS_Exit:
  RETURN
Jon McPhalen
EFX-TEK Hollywood Office

Jeffery Hamilton

Thank you for the code.  Finished product. Thank you