# SOUND

{PBASIC 1.0}

SOUND Example

Syntax: SOUND Pin, (Note, Duration {, Note, Duration...})

## Function

Generate square-wave tones for a specified duration.

- 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.

Note: See FREQOUT for all BS2 models.

## 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 255 square-wave frequencies on an I/O pin. The output pin should be connected as shown in the circuits below.

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) x 0.000083))

Note, in the above equations, Frequency is in Hertz (Hz).

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012