Digital Input and Output

'{$STAMP BS2}
' this example has switches (digial inputs) on pins 8, 14, and 15
' and digital ouputs (LEDs in this case) on pins 7, 10, and 11.
' When the switch on pin 8 is on, the LED on pin 7 goes on.
' When the switch on pin 14 is on, the LED on pin 11 goes on, and
' when the switch on pin 15 is on, the LED on pin 10 goes on.
' If no switches are on, the lights go off.

 

switch1Pin CON 8

LED1Pin CON 7


'declare all the inputs and outputs:
INPUT switch1Pin

OUTPUT LED1Pin


'turn all the LED's on, then off:
HIGH LED1Pin

PAUSE 1000
LOW LED1Pin


main:
'turn all the LED's off:
LOW LED1Pin


red: IF IN8 = 1 THEN redlight
GOTO main

redlight:
HIGH LED1Pin

GOTO main