28123 Parallax Inc, 28123 Datasheet - Page 239

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
Because each of these values occupies two bytes, accessing them with the read command
is different from accessing characters. The first 2093 is at
second 2093 is located at
+ 4
Here is a
then it places the
The next example program stores notes and durations using
FREQOUT
first few notes from the children’s song Twinkle Twinkle Little Star.
Example Program: TwinkleTwinkle.bs2
This example program demonstrates how to use the
to use the
, and the second 3136 is located at
FOR index = 0 to 6
NEXT
FOR…NEXT
command to play each note frequency for a specific duration. The result is the
READ
The values in the
the
What does the (index * 2) do? Each value stored in the
takes a word (two bytes), while each character in the
one byte. The value of
That’s fine for accessing the note characters using the command
index, noteLetter
variable needs to point twice as far down the
Frequencies + (index * 2), Word noteFreq
The Alphabet Song used by children to memorize their “ABCs” uses the same notes as
Twinkle Twinkle Little Star.
Enter and run TwinkleTwinkle.bs2
READ Notes + index, noteLetter
READ Frequencies + (index * 2), Word noteFreq
DEBUG noteLetter, "
Notes DATA
command to access the values in the lists.
Frequencies DATA
loop that places the
Frequencies + 2
Frequencies DATA
directive.
index
. The problem is that for every one byte in
", DEC noteFreq, CR
into a variable named
increases by one each time through the
Frequencies + 6
Notes DATA
. The first 3136 is located at
directive correspond with the musical notes in
Frequencies
DATA
into a variable named
.
Notes DATA
directive to store lists and how
Frequencies DATA
noteFreq
Frequencies + 0
, takes care of this.
list. The command
DATA
.
Notes
, and it uses the
directive only takes
READ Notes +
FOR…NEXT
Frequencies
noteLetter
, the
, but the
directive
index
READ
loop.
,

Related parts for 28123