28123 Parallax Inc, 28123 Datasheet - Page 215

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
Example Program: SimpleSubroutines.bs2
This example program shows how subroutines work by sending messages to the Debug
Terminal.
' What's a Microcontroller - SimpleSubroutines.bs2
' Demonstrate how subroutines work.
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG CLS, "Start main routine.", CR
What’s a label? A label is a name that can be used as a placeholder in your program.
GOSUB
ON GOTO
end with a colon, and for the sake of style, separate words with the underscore character.
When picking a name for a label, make sure not to use a reserved word. The rest of the
rules for a label name are the same as the ones for naming variables listed in the
information box on page 53.
Examine SimpleSubroutines.bs2 and try to guess the order in which the
commands will be executed.
Enter and run the program.
Compare the program’s actual behavior with your predictions.
DO
LOOP
Subroutine_Name:
RETURN
is one of the commands you can use to jump to a label. Some others are
GOSUB Subroutine_Name
DEBUG "Next command"
DEBUG "This is a subroutine..."
PAUSE 3000
, and
ON GOSUB
. You can use these commands to jump to labels. A label must
Figure 7-11
How
Subroutines
Work
GOTO
DEBUG
,

Related parts for 28123