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


loop with prop-1 & rc-4

Started by EricTheMannn, September 16, 2008, 10:18:31 AM

Previous topic - Next topic

EricTheMannn

Is it possible to add and additional code to the prop one. That will flicker lights at random & loop using k4 on the rc-4, as the" main:"program remains off until triggered?

i will post the code after work if anyone has some input i would greatly appreciate it!

thank you
-Eric
WooHoo

JonnyMac

I'm not sure I understand your question.  I think you're wanting K4 to "flicker" while you're waiting on a valid trigger; if that's the case, here you go.

' =========================================================================
'
'   File...... Flicker_K4.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 16 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   K1             =  BIT0
SYMBOL   K2             =  BIT1
SYMBOL   K3             =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  timer           = B2
SYMBOL  lottery         = W5


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

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

  SEROUT Sio, Baud, ("!!!!!!RC4", %00, "X")
  relays = IsOff


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' shake random value
  K4 = lottery                                  ' copy bit 0
  GOSUB Set_RC4
  timer = timer + 30 * Trigger                  ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.2 sec input

  ' prop code here

  GOTO Main


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

' Updates RC-4
' -- takes about 29.4 milliseconds

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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

EricTheMannn

 ;D exactly, i am sorry i couldn't have been more clear, i will add this to my existing code and thank you yet again for the help.

-Eric
WooHoo