BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – SOUND
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 445
SOUND
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
SOUND Pin, ( Note, Duration { , Note, Duration…} )
(See FREQOUT)
Function
Generate square-wave tones for a specified period.
Pin is a variable/constant (0 – 7) that specifies the I/O pin to use.
This pin will be set to output mode.
Note is a variable/constant (0 – 255) specifying the type and
frequency of the tone. 1 – 127 are ascending tones and 128 – 255 are
ascending white noises ranging from buzzing (128) to hissing (255).
Duration is a variable/constant (1 - 255) specifying the amount of
time to generate the tone(s). The unit of time for Duration is 12 ms.
Quick Facts
Table 5.119: SOUND Quick
Facts.
BS1
Units in Duration
12 ms
Available Sounds
256
Frequency Range
94.8 Hz to 10,550 Hz
Explanation
SOUND generates one of 256 square-wave frequencies on an I/O pin. The
output pin should be connected as shown in Figure 5.46.
The tones produced by SOUND can vary in frequency from 94.8 Hz (1) to
10,550 Hz (127). If you need to determine the frequency corresponding to a
given note value, or need to find the note value that will give you best
approximation for a given frequency, use the equations below.
Note = 127 – ( ((1/Frequency)-0.000095)/0.000083 )
--and--
Frequency = ( 1/(0.000095 + ((127–Note)*0.000083) )
In the above equations, Frequency is in Hertz (Hz).
All
2
1