28123 Parallax Inc, 28123 Datasheet - Page 214

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
Using Subroutines
Most of the programs you have written so far operate inside a
main activity happens inside the
add more circuits and more useful functions to your program, it can get kind of difficult
to keep track of all the code in the main routine. Your programs will be much easier to
work with if you organize them into smaller segments of code that do certain jobs.
PBASIC has some commands that you can use to make the program jump out of the main
routine, do a job, and then return right back to the same spot in the main routine. This
will allow you to keep each segment of code that does a particular job somewhere other
than your main routine. Each time you need the program to do one of those jobs, you can
write a command inside the main routine that tells the program to jump to that job, do it,
and come back when the job is done. This process is called executing a subroutine.
Figure 7-11 shows an example of a subroutine and how it’s used. The command
Subroutine_Name
the program gets to that label, it keeps running and executing commands until it gets to a
RETURN
command. In the case of the example in Figure 7-11, the next command is:
"
Next command
statement. Then, the program goes back to command that comes after the
Build the circuit shown in Figure 7-9 and Figure 7-10.
Test the 7-segment LED display to make sure it is connected properly using
SegmentTestWithHighLow.bs2 from Chapter #6, Activity #2.
".
causes the program to jump to the
DO…LOOP
, it is usually called the main routine. As you
Figure 7-10
Wiring Diagram
for Figure 7-9
Subroutine_Name:
DO…LOOP
. Since all the
label. When
GOSUB
GOSUB
DEBUG

Related parts for 28123