28123 Parallax Inc, 28123 Datasheet - Page 250

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
The
defined in beats per minute, and the program has to divide
then multiply by 4. The result is the correct value for a whole note.
This is all the same as the previous program:
Now that octaves are in the mix, the part of the code that figures out the note frequency
has changed. The
8
by 2 if you want to play notes in the 7
octave and by 8 if you want to play notes in the 5
All this
variable.
Here is how the
command grabs the octave value stored in the
between 5 and 8.
th
octave. These values can be divided by 1 if you want to play notes in the 8
wholeNote
noteOctave
noteDot
wholeNote = 60000 / BeatsPerMin * 4
DO UNTIL noteLetter = "Q"
LOOKUP
Math executes from left to right. In the calculation
beatsPerMin * 4
Then, it multiplies that result by 4.
Parentheses can be used to group operations. If you want to divide 4 into beatsPerMin
first, you can do this:
READ Notes + index, noteLetter
LOOKDOWN noteLetter,
LOOKUP offset,
READ Octaves + index, noteOctave
variable is calculated using the
command does is place a note from the 8
noteFreq
LOOKUP
VAR
VAR
command’s table of values contains note frequencies from the
wholeNote = 60000 / (beatsPerMin * 4)
variable is adjusted for the correct octave. First, the
, the BASIC Stamp first calculates
Nib
Bit
[ 4186, 4435, 4699, 4978, 5274,
[ "C",
th
5588, 5920, 6272, 6645, 7040,
7459, 7902,
octave, by 4 if you want to play notes in the 6
"F",
"b",
BeatsPerMin
Octaves DATA
"d",
"g",
"B",
th
octave. The division happens next.
"D",
"G",
"P",
BeatsPerMin
0,
th
wholeNote = 60000 /
. The tempo of the song is
60000 / beatsPerMin
octave into the
. This could be a value
"e",
"a",
"Q"
0
"E",
"A",
into 60000 ms,
], offset
], noteFreq
.
noteFreq
th
octave,
READ
.
th

Related parts for 28123