November 21, 2024, 12:08:34 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Program not resetting

Started by dwalker, October 17, 2008, 11:44:53 PM

Previous topic - Next topic

dwalker

This is my first attempt at a full program. I think I have all my timing down but it is not resetting like I think it should. Any help would be appreciated.


' ---- [ I/O Definitions ] ----------------------
SYMBOL  Trigger   = PIN7
SYMBOL  Valve     = PIN4
SYMBOL  Strobe    = PIN3
SYMBOL  Lamp      = PIN2
SYMBOL  SND       = PIN0


' ---- [ Constants ] ----------------------
SYMBOL  On    = 1
SYMBOL  Off   = 0

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


SYMBOL  Reps            = B2
SYMBOL  LightIt         = B0
SYMBOL  Delay           = W2
SYMBOL  Timer           = W4



' ---- [ EEPROM Data ] --------------------
'
' ---- [ Initialization ] -----------------
LOW 2                  'Lights on (nc switch)
LOW 4                  'Valve off
LOW 3                  'Strobe off
LOW 0                  'Sound off



' ---- [ Main Code ] ----------------------

Main:
          DEBUG CLS,"Ready",CR

    IF Trigger = Off THEN Main    'Wait for Victim
          DEBUG "Triggered",CR

Run:

  FOR Reps = 5 TO 0 STEP -1
      DEBUG CLS, "Start Audio in ",#Reps, CR
      PAUSE 1000
  NEXT

    HIGH 0                  'Sound On
          DEBUG "AUDIO STARTS", CR

  FOR Reps = 12 TO 0 STEP -1
      DEBUG CLS, "Hit Lights in ",#Reps, CR
      PAUSE 1000
  NEXT
    HIGH  2              'Lights On
    HIGH 3                'Start Strobe

          DEBUG "LIGHTS Off ", CR

'Start Door Slamming
  FOR Reps = 3 TO 0 STEP -1
      DEBUG CLS, "Slam door in ",#Reps, CR
      PAUSE 500
  NEXT

  FOR Reps = 15 TO 0 STEP -1
          DEBUG CLS, "BANG!!: Rep ",#Reps,CR

    HIGH  4
    PAUSE 100
    LOW   4
    RANDOM Timer            'Start Random function
    Delay = Timer // 3 +1   'Create Delay 1-3 seconds
    Delay = Delay * 100    'Convert to Milliseconds
    PAUSE Delay

  NEXT

    LOW 3                   'Turn off Strobe
    LOW 2                   'Turn Lights back on

    FOR Reps = 15 TO 0 STEP -1
      DEBUG CLS, "Sound stops in ",#Reps, CR
      PAUSE 500
  NEXT

    LOW 0                   'Sound off
  FOR Reps = 120 TO 0 STEP -1
      DEBUG CLS, "Reset in ",#Reps, CR
      PAUSE 1000
  NEXT

    GOTO Main


livinlowe

Try this:

' ---- [ I/O Definitions ] ----------------------
SYMBOL  Trigger   = PIN7
SYMBOL  Valve     = PIN4
SYMBOL  Strobe    = PIN3
SYMBOL  Lamp      = PIN2
SYMBOL  SND       = PIN0


' ---- [ Constants ] ----------------------
SYMBOL  On    = 1
SYMBOL  Off   = 0

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


SYMBOL  Reps            = B2
SYMBOL  LightIt         = B0
SYMBOL  Delay           = W2
SYMBOL  Timer           = W4



' ---- [ EEPROM Data ] --------------------
'
' ---- [ Initialization ] -----------------
Reset:

LOW 2                  'Lights on (nc switch)
LOW 4                  'Valve off
LOW 3                  'Strobe off
LOW 0                  'Sound off



' ---- [ Main Code ] ----------------------

Main:
          DEBUG CLS,"Ready",CR

    IF Trigger = Off THEN Main    'Wait for Victim
          DEBUG "Triggered",CR

Run:

  FOR Reps = 5 TO 0 STEP -1
      DEBUG CLS, "Start Audio in ",#Reps, CR
      PAUSE 1000
  NEXT

    HIGH 0                  'Sound On
          DEBUG "AUDIO STARTS", CR

  FOR Reps = 12 TO 0 STEP -1
      DEBUG CLS, "Hit Lights in ",#Reps, CR
      PAUSE 1000
  NEXT
    HIGH  2              'Lights On
    HIGH 3                'Start Strobe

          DEBUG "LIGHTS Off ", CR

'Start Door Slamming
  FOR Reps = 3 TO 0 STEP -1
      DEBUG CLS, "Slam door in ",#Reps, CR
      PAUSE 500
  NEXT

  FOR Reps = 15 TO 0 STEP -1
          DEBUG CLS, "BANG!!: Rep ",#Reps,CR

    HIGH  4
    PAUSE 100
    LOW   4
    RANDOM Timer            'Start Random function
    Delay = Timer // 3 +1   'Create Delay 1-3 seconds
    Delay = Delay * 100    'Convert to Milliseconds
    PAUSE Delay

  NEXT

    LOW 3                   'Turn off Strobe
    LOW 2                   'Turn Lights back on

    FOR Reps = 15 TO 0 STEP -1
      DEBUG CLS, "Sound stops in ",#Reps, CR
      PAUSE 500
  NEXT

    LOW 0                   'Sound off
  FOR Reps = 120 TO 0 STEP -1
      DEBUG CLS, "Reset in ",#Reps, CR
      PAUSE 1000
  NEXT

    GOTO Reset

Shawn
Scaring someone with a prop you built -- priceless!

dwalker

Thank you. It turned out to be a faulty PIR. All is well.