28123 Parallax Inc, 28123 Datasheet - Page 232

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
duration
frequencies of 2000, then 2020, then 2040, and so on, up through 2500 to the piezo
speaker. When the frequency loop is finished, the
of its 15 passes. So it subtracts one from the value of
frequency
Example Program: NestedLoops.bs2
To better understand how nested
command to show the value of a much less complicated version of the nested loop used
in ActionTones.bs2.
' What's a Microcontroller - ActionTones.bs2
' Demonstrate how different combinations of pause, duration, and frequency
' can be used to make sound effects.
'{$STAMP BS2}
'{$PBASIC 2.5}
duration
frequency
DEBUG "Alarm...", CR
DEBUG "Robot reply...", CR
PAUSE 100
FREQOUT 9, 500, 1500
PAUSE 500
FREQOUT 9, 500, 1500
PAUSE 500
FREQOUT 9, 500, 1500
PAUSE 500
FREQOUT 9, 500, 1500
PAUSE 500
PAUSE 100
FREQOUT 9, 100, 2800
Enter and run NestedLoops.bs2.
Examine the Debug Terminal output and verify how the duration and
frequency arguments change each time through the loop.
FOR duration = 15 TO 1
NEXT
variable starts at 15, then the
loop all over again.
FOR frequency = 2000 TO 2500 STEP 15
NEXT
FREQOUT 9, duration, frequency
VAR
VAR
Word
Word
FOR…NEXT
loops work, NestedLoops.bs2 uses the
frequency
duration
loop takes over and sends
duration
loop has only repeated one
and repeats the
DEBUG

Related parts for 28123