Assuming that you already set your pins as inputs & outputs; a code as below should work.
edit : Also, is it a push-pull button or a holder switch?
Code:
OUTPUT PORTB.3 'make pin an output pin
OUTPUT PORTB.4 'make pin an output pin
INPUT PORTB.5 'make pin an input pin
GreenLED VAR PORTB.3 'assign a name to the pin
RedLEd VAR PORTB.4 'assign a name to the pin
Emergency VAR PORTB.5 'switch pin
Begin:
GreenLED = 0 'Initially OFF.
RedLEd = 1 'Initially ON.
main :
IF Emergency = 1 Then 'Someone pushed the button.
WHILE Emergency = 1 : wend 'Wait for finger release.
TOGGLE GreenLED 'Change the status.
TOGGLE RedLEd 'Change the status.
ENDIF
GOTO main
Last edited by sayzer; - 11th October 2006 at 16:16.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks