If you are using a BASIC Stamp to control functions of an electronics project, you will be writing code in Parallax BASIC (PBASIC). Using comments in your code will help you to remember what each little chunk of code actually does.

A comment is a bit of text that provides an explanation of your code. PBASIC completely ignores comments, so you can put any text you wish in a comment. Using plenty of comments in your programs to explain what your program does and how it works is a good idea.

A comment begins with an apostrophe. When PBASIC sees an apostrophe on a line, it ignores the rest of the line. Thus, if you place an apostrophe at the beginning of a line, the entire line is considered to be a comment. If you place a comment in the middle of a line (for example, after a statement), everything after the apostrophe is ignored.

It’s a common programming practice to begin a program with a group of comments that indicates what the program does, who wrote it, and when. This block of comments should also indicate what I/O devices are expected to be connected to the BASIC Stamp. This program includes both types of comments.

You may notice that the $PBASIC and $STAMP directives begin with an apostrophe. Technically, these lines are treated as comments.

' LED Flasher Program
' Doug Lowe
' July 10, 2011
' This program flashes LEDs connected to pins 0, 2, 4, 6, 8, and 10
' at one-half second intervals.
' {$PBASIC 2.5}
' {$STAMP BS2}
 HIGH 0   'Turn the LEDs on
 HIGH 10
 PAUSE 500  'Wait one-half second
 LOW 0    'Turn the LEDs off
 LOW 2
 LOW 4
 LOW 6
 LOW 8
 LOW 10
 PAUSE 500  'Wait one-half second
 GOTO Main