Shop OBEX P1 Docs P2 Docs Learn Events
Con function confusion.... — Parallax Forums

Con function confusion....

troikatroika Posts: 14
edited 2006-09-11 17:01 in BASIC Stamp
HELLO,
PASTED BELOW IS MY (1ST EVER) SCRIPT.
I AM CONTROLLING A NUMBER OF REED SWITCHES.

WHEN I TRY TO RUN THIS TO THE STAMP I GET:
Expected a constand! with PRESS CON HIGH with 'HIGH' hi-lited

i just want to substitute PRESS for HIGH and RELEASE for LOW

thanks

troika

' {$STAMP BS2}
' {$PBASIC 2.5}


TIMES VAR BYTE

DIR0=1
DIR1=1
DIR2=1
DIR3=1
DIR4=1 ' make Pins 0-6 an output
DIR5=1
DIR6=1

POWER CON 3
MAGIC CON 0
MUTE CON 1 'names pin no.s as functions on remote
CHUP CON 6
CHDN CON 2
VOLUP CON 5
VOLDN CON 4

PRESS CON HIGH
RELEASE CON LOW

FOR TIMES = 0 - 3

PRESS CHUP
PAUSE 500
RELEASE CHUP
PAUSE 500

NEXT

PAUSE 20000 'CHANNEL UP 3 TIMES


PRESS VOLUP
PAUSE 5000
RELEASE VOLUP
PAUSE 500


FOR TIMES = 0 TO 20

PRESS MUTE
PAUSE 200
RELEASE MUTE
PAUSE 200

NEXT

PAUSE 22000

PRESS MUTE
PAUSE 500
RELEASE CHDN

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-11 16:44
    Hello,

    ·· You cannot define HIGH as a constant, since it's a PBASIC keyword.· As a side-note you will then get the same error for LOW.· Take care.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • troikatroika Posts: 14
    edited 2006-09-11 16:50
    balls

    oh well

    can i make a shortcut for

    HIGH x PAUSE 500 LOW x PAUSE 500 (where x is the pin e.g. CHUP)
    and name is something like: PRESS01

    so i could run:
    PRESS01 CHUP

    for the whole function?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-11 17:01
    I'm not sure I understand the context of your usage of HIGH/LOW.· If you look these up you will find that they are commands to make an I/O pin an output HIGH or output LOW, respectively.· Now, if you needed them to represent a high or low condition, then you could define your constant as:

    PRESS CON 1

    RELEASE CON 0

    Seems like this would work the same...Ad for using PAUSE with parameters you could say:

    PAUSE 500 * PRESS

    which would cause a 500 mS pause...or

    PAUSE 500 * RELEASE

    which would cause almost no pause.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.