' PULSIN.BS1
' This program uses PULSIN to measure a pulse generated by discharging a
' 0.1 uF capacitor through a 1K resistor. Pressing the switch generates
' the pulse, which should ideally be approximately 120 us (12 PULSIN units
' of 10 us) long. Variations in component values may produce results that
' are up to 10 units off from this value. For more information on calculating
' resistor-capacitor timing, see the RCTIME command.
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL Pulse = 7 ' pulse input pin
SYMBOL time = W1 ' pulse width (10 uS units)
Main:
PULSIN Pulse, 1, time ' measure positive pulse
IF time = 0 THEN Main ' if 0, try again
DEBUG CLS, time ' else display result
GOTO Main
END
Lesezeichen