5: BASIC Stamp Command Reference – RCTIME
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 259
Demo Program (RCTIME2.bs2)
' This program illustrates the use of RCTIME as a fast stopwatch. The program energizes
' a relay coil, then measures how long it takes for the relay contacts to close. Figure 5.30
' shows the circuit. Note that RCTIME doesn't start timing instantly.
'{$STAMP BS2} 'STAMP directive (specifies a BS2)
Result VAR WORD
Again:
Low 6 'Energize relay coil.
RCTIME 7, 1, Result 'Measure time to contact closure.
DEBUG "Time to close: ", DEC Result, CR
HIGH 6 'Release the relay.
PAUSE 1000 'Wait a second.
GOTO Again 'Do it again.
relay
contacts
relay coil
10 k
Ω
Relay: 5Vdc reed
relay with 20mA
coil, eg., Radio
Shack 275-232
P6
P7
Vdd
Figure 5.30: Relay circuit for Demo
Program 2.