'{$STAMP BS2} '*** Listing 2 of 4: Turning an LED on and off with a switch *** 'SPST switch: 'one side to +5V (VDD) 'other side to BS2 pin 1 (input) + 10K resistor (BR-BL-OR) '10K resistor to ground (VSS) 'LED: 'short pin (cathode) to ground (VSS) 'long pin (anode) to 220 ohm resistor (RED-RED-BR) '220 ohm resistor to BS2 pin 8 (output) switchPin var in1 'set variable to input pin 1 state switchPrev var bit 'bit for keeping track of previous pin state ledPin con 8 'output pin for LED start: debug "STAMP PROGRAM STARTING...",cr label1: pause 50 if switchPin <> switchPrev then switchChange goto label1 switchChange: switchPrev = switchPin if switchPin = 1 then switchOn debug "SWITCH OFF ",dec switchPin,cr goto offLED switchOn: debug "SWITCH ON ",dec switchPin,cr goto onLED offLED: low ledPin debug "LED OFF",cr goto label1 onLED: high ledPin debug "LED ON",cr goto label1 '