28123 Parallax Inc, 28123 Datasheet - Page 237

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
Programming Musical Notes
The
to play music using a piezospeaker involves following a variety of rules used in playing
music using any other musical instrument. These rules apply to the same elements that
were used to make sound effects, frequency, duration, and pause. This next example
program plays some of the musical note frequencies on the piezospeaker, each with a
duration of half a second.
Example Program: DoReMiFaSolLaTiDo.bs2
' What's a Microcontroller - DoReMiFaSolLaTiDo.bs2
' Send an octave of half second tones using a piezoelectric speaker.
'{$STAMP BS2}
'{$PBASIC 2.5}
'Solfege
DEBUG "Do...", CR:
DEBUG "Re...", CR:
DEBUG "Mi...", CR:
DEBUG "Fa...", CR:
DEBUG "Sol..", CR:
DEBUG "La...", CR:
FREQOUT
Tuning Method: The keyboard in Figure 8-3 uses a method of tuning called equal
temperament. The frequencies are determined using a reference note, then multiplying it by
2
multiply by 2
B6, and so on. Here is an example of calculating the frequency for B6 using A6 as a
reference frequency:
Enter and run DoReMiFaSolLaTiDo.bs2
(n/12)
command is also useful for musical notes. Programming the BASIC Stamp
The frequency of A6 is 1760
2
1760 X 1.224 = 1975.5
1975.5 is the frequency of B6
for values of n = 1, 2, 3, etc. For example, you can take the frequency for A6, and
(2/12)
= 1.1224
(1/12)
Tone
FREQOUT 9,500,1047
FREQOUT 9,500,1175
FREQOUT 9,500,1319
FREQOUT 9,500,1396
FREQOUT 9,500,1568
FREQOUT 9,500,1760
to get the frequency for A6#. Multiply it by 2
' C6
' D6
' E6
' F6
' G6
' A6
Note
(2/12)
to get the frequency for

Related parts for 28123