Important First Differences
As with moving from any programming language to another the user has a lot of translating to do. Which commands are equivalent? How are variables declared? What differences are there in syntax? This page will hopefully explain some of the first differences you will have to get used to.
Headers:
In PBASIC every program starts with 2 directives,and both are necessary for the programming environment to check each program's syntax (to make sure it complies with the version of PBASIC in use) and in order to properly tokenize the code for the Basic Stamp being programmed (PBASIC programs are not "compiled" but are rather "tokenized" before being downloaded to the Basic Stamp)
' {$STAMP BS2}
' {$PBASIC 2.5}
In this example we are telling the tokenizer that we are programming a BS2, or Basic Stamp 2, and that we are writing our code in PBASIC version 2.5.
Arduino code uses no headers, as such. Arduino code does, however, use a void setup() statement. More on this later.
Comments:
In PBASIC we use apostrophes to start comment lines. Comments can be their own line or can come after program code on the line. PBASIC does not have multi-line commenting. The one exception is with the Stamp Directives illustrated above.
'this line would be commented out in PBASIC
in Arduino we use 2 forward slashes to start comment lines. Arduino also uses a forward slash and asterisk to open and close multi-line comments.
//this line would commented out in Arduino
/*this set of
lines would be
commented out
in Arduino*/
Variable Declaration:
Curly Braces:
Semicolons:
Analog Pins:
Comments (0)
You don't have permission to comment on this page.