potPin con 7
spkrPin con 9

' declare variables:
potVar var word ' a word-sized variable to hold the results of the RCTIME command
byteVar var byte ' a byte-sized variable that will vary proprtional to potVar
output pwrLED 'light an LED on pin 8

high pwrLED 'just so we know the stamp's working

main:
high potPin 'put voltage out to the capacitor
pause 1 'hold a millisecond (0.4 ms on the BS2-SX)
rctime potPin, 1, potVar 'time how long the cap takes to discharge
debug ?potVar
byteVar = potVar /3 'convert potvar to a smaller number
pwm LED2, byteVar, 10 'output a varying voltage based on bytevar
freqout spkrPin,10,byteVar*50 'make a varying sound on the speaker
debug ?byteVar
goto main

Schematic: