November 22, 2024, 12:47:45 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.


using two differnt codes for two differnt triggers

Started by reddragon, March 15, 2009, 03:32:55 PM

Previous topic - Next topic

reddragon

  ???I was wounding if there is a way to write two different codes in one and have two triggers PIR and a matsw and have a code for the PIR and a different code for the matsw? If so how would that look? thanks everyone

JonnyMac

As ever, I'm still confused by your question.  Do you want two different behaviors for one prop based on the input, or are you trying to control two props with on controller?  If the latter, using one Prop-1 per prop is the cheapest way to go.  You can control two props with one controller but you're usually limited to sequencer type operations and the code is really difficult to write and maintain, especially if you're forced into using a state-machine.  I can write those kinds of programs but I don't think you're at that level yet.

Jon McPhalen
EFX-TEK Hollywood Office

reddragon

yes two differnt behavors basd on the active trigger at the time. sorry  :-[

JonnyMac

If the behaviors aren't running at the same time the coding is pretty straightforward for the Prop-1 or Prop-2.
Jon McPhalen
EFX-TEK Hollywood Office

reddragon

I would jest use two different IF THEN's  for the triggers am i right for example: if mats = no then pir and if PIR= no then timer does that sound right?

livinlowe

That sounds like how I would do it. Do you have any code to try?
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

Here's how I scan and deal with multiple inputs:

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


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN
PIR             PIN     14                      ' SETUP = DN
MatSw           PIN     13                      ' SETUP = DN


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

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

Yes             CON     1
No              CON     0


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

sensors         VAR     Byte
pirOn          VAR     sensors.BIT6
matSwOn        VAR     sensors.BIT5

idx             VAR     Byte


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000000 : DIRL = %00000000           ' set outputs


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

Main:
  sensors = %01100000                           ' assume active
  FOR idx = 1 TO 20
    sensors = sensors & INH                     ' scan inputs
    PAUSE 5                                     ' loop pad
  NEXT
  IF sensors = %00000000 THEN Main              ' if none, try again


Check_PIR:
  IF pirOn = Yes THEN
    ' pir code
    GOTO Main
  ENDIF


Check_Mat:
  IF matSwOn = Yes THEN
    ' mat switch code
    GOTO Main
  ENDIF


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


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


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

reddragon

 Thanks Jon and Laylowe that is what i was hoping it would look like. time to bring the dead back. ;D