How can I do this (reversing high & low states depending on deployment & user need)


Results 1 to 6 of 6

Threaded View

  1. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: How can I do this (reversing high & low states depending on deployment & user nee

    Code:
    EE_Polarity DATA 0            ; Factory Default
    SW1         VAR PORTB.0       ; Switch input pin
    mosfet_gate VAR PORTB.1       ; mosfet output
    Polarity    VAR BIT           
    
    READ EE_Polarity, Polarity
    IF !SW1 THEN WRITE EE_Polarity, !Polarity
    READ EE_Polarity, Polarity
    
    mosfet_gate = 1 ^ Polarity    ; Turn OFF
    OUTPUT mosfet_gate
    ;----------------------------------------------
    
    mosfet_gate = 0 ^ Polarity    ; Turn ON
    mosfet_gate = 1 ^ Polarity    ; Turn OFF
    Last edited by Darrel Taylor; - 17th May 2012 at 04:38. Reason: Oops, forgot to set the pin to output.
    DT

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