© Parallax, Inc. • Reed Switch (#910-27225) • v1.0 5/07 Page 3 of 3
BASIC Stamp
®
2 Program
This program displays the current status (open/closed) of the Reed Switch in the DEBUG window. This
could be used to calibration of the switch/magnet or for testing/debugging purposes.
' =========================================================================
'
' File...... ReedSwitchTest.bs2
' Purpose... Display Status Of Reed Switch
' Author.... Parallax, Inc.
' E-mail.... [email protected]
' Started... 05-15-2007
' Updated...
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ I/O Definitions ]-------------------------------------------------
ReedSwitch PIN 0 ' Reed Switch Input Pin
' -----[ Program Code ]----------------------------------------------------
Main:
DO
IF IN0 = 0 THEN ' Is Reed Switch Closed?
DEBUG HOME, "CLOSED", CLREOL ' CLOSED. Display It
ELSE
DEBUG HOME, "OPEN", CLREOL ' OPEN. Display It
ENDIF
PAUSE 150 ' Wait A While
LOOP ' Keep Going