Syntax Error associated with PIN
Robomanjosh
Posts: 4
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
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 Williams
Applications Engineer, Parallax
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
And your code has 2 "PBasic" version identifiers -- when using "PIN" it should only have
the "{PBasic 2.5}" one.
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
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