28123 Parallax Inc, 28123 Datasheet - Page 263

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
' -----[ Subroutine - Check For '.' Indicating 1.5 Duration ]-------------
' -----[ Subroutine - Find Comma and Play Note/Duration ]-----------------
How MicroMusicWithRtttl.bs2 Works
This example program is fun to use, and it shows the kind of code you will be able to
write with some practice. However, it was included in this text more for fun than for the
coding concepts it employs.
If you examine the code briefly, you might notice that you have already used all of the
commands and operators in the program. Here is a list of the elements in this application
example that should, by now, be familiar:
CheckForDot:
PlayNote:
ENDIF
RETURN
READ RTTTL_File + counter, char
SELECT char
ENDSELECT
RETURN
READ RTTTL_File + counter, char
SELECT char
ENDSELECT
RETURN
CASE "."
CASE ","
Comments to help explain your code
duration = duration * 3 / 2
counter = counter + 1
counter = counter + 1
READ Octave8 + (index * 2), Word noteFreq
noteOctave = 8 - noteOctave
noteFreq = noteFreq / (DCD noteOctave)
IF noteFreq = 0 THEN
ELSE
ENDIF
FREQOUT SpeakerPin, duration, noteFreq
PAUSE duration
' Check for dot indicating
' multiply duration by 3/2.
' If dot found, multiply by
' 3/2 and increment counter,
' else, do nothing and
' return.
' Find last comma in the
' current note entry.
' fetch the note frequency
' from data, and play it, or
' pause if frequency = 0.
Then,

Related parts for 28123