28125 Parallax Inc, 28125 Datasheet - Page 156

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
Here’s an example program that has two subroutines. One subroutine makes a high
pitched tone while the other makes a low pitched tone. The commands between
LOOP
Example Program – TwoSubroutines.bs2
' Robotics with the Boe-Bot - TwoSubroutines.bs2
' This program demonstrates that a subroutine is a reusable block of commands.
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
LOOP
High_Pitch:
Low_Pitch:
Let’s try putting the forward, left, right, and backward navigation routines inside
subroutines. Here’s an example:
DEBUG "Command in subroutine", CR
PAUSE 1000
RETURN
GOSUB High_Pitch
DEBUG "Back in main", CR
PAUSE 1000
GOSUB Low_Pitch
DEBUG "Back in main again", CR
PAUSE 1000
DEBUG "Repeat...",CR,CR
DEBUG "High pitch", CR
FREQOUT 4, 2000, 3500
RETURN
DEBUG "Low pitch", CR
FREQOUT 4, 2000, 2000
RETURN
call each of the subroutines in turn. Try this program and note the effect.
Watch your Debug Terminal, and press the Reset button a few times. You
should get the same set of three messages in the right order each time.
Enter, save, and run TwoSubroutines.bs2
DO
and

Related parts for 28125