Shop OBEX P1 Docs P2 Docs Learn Events
Syntax Error associated with PIN — Parallax Forums

Syntax Error associated with PIN

RobomanjoshRobomanjosh Posts: 4
edited 2005-08-29 15:53 in BASIC Stamp
I keep on getting a Syntax Error: Expected ' :' or End-of-LIne

With

Button1 PIN 8
Button PIN 12

I am using a Board of Education with a BS2
With the Quad-Crawler robot kit
I followed the instructions but, still getting a syntax error
Please Write back, if you can help
Sample of Program:

' ================================================================

' {$PBASIC 2.0}

'{$PBASIC 2.5}

' File ...... QuadCrawler_ Push Button Test

'
I/O define
:

Button1 PIN 8

Button2 PIN 12

'
Variables

btnVal1 VAR Bit 'state of button

'---intialize

Setup:

DEBUG CLS, "Button Test"

'
Program Code

Main:

DEBUG CRSRXY (2), 0, 2

btnVal = Button1

DEBUG "Button on P8....", BIN1 btnVal

GOSUB Show_State

btnVal = Button2

DEBUG " Button on P12...", BIN1 btnVal

GOSUB Show_State

GOTO Main

'
Subroutine

Show_State:

IF (btnVal = 1) THEN

DEBUG " (Pressed)", CLREOL, CR

ELSE

DEBUG " (Not Pressed)" , CLREOL, CR

END IF

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-26 19:59
    You have two $PBASIC directives -- remove the first and replace it with $STAMP BS2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • RobomanjoshRobomanjosh Posts: 4
    edited 2005-08-29 14:54
    That still didn't work
    The main problem is the lines that define the PIN
    Every program that is discussed in the manual for the quad crawler, have the same problem when it comes to assigning the PSC.
    So is there something that I'm missing
    Do you know of a piece of code that could check that
    Thanks
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-08-29 15:01
    Isn't "Button" a PBasic keyword?

    And your code has 2 "PBasic" version identifiers -- when using "PIN" it should only have
    the "{PBasic 2.5}" one.
  • aliniousalinious Posts: 51
    edited 2005-08-29 15:23
    In your pin definitions you can not use "Button" to define a PIN constant. "Button" is a keyword used by the Basic Stamp compiler and is further detailed in the Basic Stamp Manual 2.1 on page 133. (Instead of using "Button" to define the PIN, try Button_0 to define the PIN). This URL, www.parallax.com/dl/docs/prod/stamps/BasicStampMan.pdf, will download the PDF version of the Basic Stamp Manual 2.1 which explains all of the commands that are used to program the Basic Stamps.

    Also, like Jon had said, you can only have one $PBASIC directive in your program. Typically, I would go with the PBASIC 2.5 directive since it works on all Basic Stamp 2 models and supports the PIN definition. The beginning of all basic stamp programs should have a $Stamp directive and $Pbasic directive.

    Post Edited (alinious) : 8/29/2005 3:33:44 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-29 15:53
    That is not true. You may use keywords as part of other words -- but one must be caution that there' is a modification.

    The original program has a syntax error related with the use of CRSRXY as well. In short there errors are typographic -- there is nothing wrong with BASIC Stamp or the editor. Go through and correct each one -- one at a time -- and you'll be fine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.