2
2
e
Table 5.12: FREQOUT Quick
Facts.
S
FREQOUT.
IMPLEST FORM OF
G
ENERATING TWO TONES AT ONCE
5: BASIC Stamp Command Reference – FREQOUT
FREQOUT
1
(See SOUND)
2
2
FREQOUT Pin, Period, Freq1 {, Freq2}
sx
p
Function
Generate one or two sine-wave tones for a specified period.
• Pin is a variable/constant/expression (0 – 15) that specifies the I/O
pin to use. This pin will be set to output mode.
• Period is a variable/constant/expression (0 - 65535) specifying the
amount of time to generate the tone(s). The unit of time for Period is
described in Table 5.12.
• Freq1 is a variable/constant/expression (0 – 32767) specifying
frequency of the first tone. The unit of Freq1 is described in Table
5.12.
• Freq2 is an optional argument exactly like Freq1. When specified,
two frequencies will be mixed together on the specified I/O pin.
Quick Facts
Units in Period
Units in Freq1
and Freq2
Range of
frequency
Explanation
FREQOUT generates one or two sine waves using a pulse-width
modulation algorithm. The circuits shown in Figure 5.4 will filter the
signal in order to play the tones through a speaker or audio amplifier.
Here's a simple FREQOUT command:
FREQOUT 2, 1000, 2500
On the BS2, this command generates a 2500 Hz tone for 1 second (1000 ms)
on I/O pin 2. See Table 5.12 for timing data on other BASIC Stamps.
To play two tones on the same I/O pin at once:
.
BS1
BS2
BS2e BS2sx BS2p
BS2, BS2e
1 ms
1 Hz
0 to 32767 Hz
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 123
BS2sx
0.4 ms
2.5 Hz
0 to 81.917 kHz
0 to 123.531 kHz
BS2p
0.265 ms
3.77 Hz
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?