Shop OBEX P1 Docs P2 Docs Learn Events
What is a microcontroller? Page 81 — Parallax Forums

What is a microcontroller? Page 81

Bibliophile6Bibliophile6 Posts: 9
edited 2007-02-13 21:35 in BASIC Stamp
The code for this set up:

near the:·········· IF (IN3 = 1) THEN··················

·· I get an error message when running that says, "Expected a label."







What exactly does it want me to do?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-13 20:15
    You may not have entered the program correctly. There are two variations of the IF/THEN statement. One expects a label after the THEN. The other expects a line with an ENDIF (or ELSE) to follow. Look in the PBasic Manual under the IF statement for examples and a discussion of syntax.
  • Bibliophile6Bibliophile6 Posts: 9
    edited 2007-02-13 20:16
    ' {$STAMP BS2}
    ' What's a Microcontroller - PushbuttonControlledLed.bs2
    ' Check pushbutton state 10 times per second and blink LED when pressed.

    ' {PBASIC 2.5}
    DO
    · DEBUG HOME
    · DEBUG ? IN4
    · DEBUG ? IN3
    · IF (IN3 = 1) THEN
    ··· HIGH 14
    ··· PAUSE 50
    · ELSEIF (IN4 =1) THEN
    ··· HIGH 15
    ··· PAUSE 50
    · ELSE
    ··· PAUSE 50
    · ENDIF
    · LOW 14
    · LOW 15
    · PAUSE 50
    LOOP
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-13 20:30
    You need a "$" in front of the "PBASIC". Otherwise, it looks just like an ordinary comment. Without the "{$PBASIC 2.5}", the compiler thinks you're using PBasic 2.0 which does not allow the multi-line IF/THEN statement.
  • Bibliophile6Bibliophile6 Posts: 9
    edited 2007-02-13 20:33
    oh! Thank you [noparse]:)[/noparse]

    It is allways the most simple things that can be the problem. Sorry about that.
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2007-02-13 21:35
    I've done that!·

    You can spare yourself the typing (and typos) by inserting those directives with the toolbar buttons, as on page 21.·

    -Stephanie Lindsay

    Editor, Parallax Inc.
Sign In or Register to comment.