
Code:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
' control an LED switch a switch
' using an IF..THEN structure
' ****** variables ************
mySwitch VAR BIT ' looking at a switch so only a BIT is required
' ****** setup ********
myLed CON 1 ' connect a digital out to this PIN
' **** processing ************
DO
'read the state of switch
mySwitch = IN0
DEBUG ? mySwitch
' write state of switch to myLED
IF mySwitch = 0 THEN
LOW myLed
ELSE
HIGH myLed
ENDIF
LOOP
Photos:



Video:
Resource: here.








