28123 Parallax Inc, 28123 Datasheet - Page 229

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
vibrates, and it causes changes in air pressure just as a guitar string does. As with the
guitar string, your ear detects the changes in air pressure caused by the piezoelectric
speaker, and it typically sounds like a beep or a tone.
Programming Speaker Control
The
make sound. The BASIC Stamp Manual shows the command syntax as this:
As with most of the other commands used in this book,
choose which BASIC Stamp I/O pin to use. The
the
argument is used to set the frequency of the tone, in Hertz. There is an optional
argument that can be used to mix frequencies.
Here is how to send a tone to I/O pin P9 that lasts for 1.5 seconds and has a frequency of
2 kHz:
Example Program: TestPiezoWithFreqout.bs2
This example program sends the 2 kHz tone to the speaker on I/O pin P9 for 1.5 seconds.
You can use the Debug terminal to see when the speaker should be beeping and when it
should stop.
' What's a Microcontroller - TestPiezoWithFreqout.bs2
' Send a tone to the piezo speaker using the FREQOUT command.
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Tone sending...", CR
FREQOUT 9, 1500, 2000
DEBUG "Tone done."
FREQOUT
FREQOUT
FREQOUT Pin, Duration, Freq1 {, Freq2}
FREQOUT 9, 1500, 2000
Enter and run TestPiezoWithFreqout.bs2.
Verify that the speaker makes a clearly audible tone during the time that the
Debug Terminal displays the message “Tone sending…”
command how long the tone should play, in milliseconds. The
command is a convenient way of sending high/low signals to a speaker to
Duration
Pin
argument is a value that tells
is a value you can use to
Freq1
Freq2

Related parts for 28123