'{$STAMP BS2} '*** Listing 1 of 4: Reading 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) switchPin var in1 'set variable to input pin 1 state switchPrev var bit 'bit for keeping track of previous pin state start: debug "STAMP PROGRAM STARTING...",cr label1: pause 50 if switchPin <> switchPrev then switchChange goto label1 switchChange: switchPrev = switchPin if switchPin = 1 then switchOn '(you can pretend there's an 'else' here) debug "SWITCH OFF ",dec switchPin,cr'(this line runs only if switchPin = 0) goto label1 switchOn: debug "SWITCH ON ",dec switchPin,cr goto label1