a switch and 2LED


Results 1 to 5 of 5

Threaded View

  1. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    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

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts