27220 Parallax Inc, 27220 Datasheet - Page 120

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
' -----[ Constants ]-------------------------------------------------------
TAdj
FAdj
Threshold
NoteTm
' -----[ Variables ]-------------------------------------------------------
tone
' -----[ Program Code ]----------------------------------------------------
Main:
Behind the Scenes
A Theremin is an interesting musical device used to create those weird, haunting
sounds often heard in old horror movies. This version uses the light falling onto a
photocell to create the output tone.
Since the photocell is a resistive device, RCTIME can be used to read its value.
FREQOUT is used to play the note. The constant, Threshold, is used to control the
cutoff point of the Theremin. When the photocell reading falls below this value, no
sound is played. This value should be adjusted to the point where the Theremin
stops playing when the photocell is not covered in ambient light.
Behind the Scenes…Going Deeper
You may wonder how the BASIC Stamp is able to create a musical note using a pure
digital output. The truth is that it gets a little help from the outside world. At the
DO
LOOP
HIGH PitchCtrl
PAUSE 1
RCTIME PitchCtrl, 1, tone
tone = tone */ FAdj
IF (tone > Threshold) THEN
ENDIF
FREQOUT Speaker, NoteTm */ TAdj, tone
CON
CON
CON
CON
VAR
$100
$100
200
40
Word
' time adjust factor
' frequency adjust factor
' cutoff frequency to play
' note timing
' frequency output
' discharge cap
' for 1 ms
' read the light sensor
' scale input
' play?

Related parts for 27220