Inverting numbers


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    42

    Default Inverting numbers

    Hello all,
    I my most recent project I need an algorithm that will convert low numbers into high ones and vice versa. For instance, I need 255 to be 0, or 1, and 2 to be 255. Im reading these numbers from a pot and need to reverse them to get an accurate speed readout. Any ideas? Thanks for reading. Happy New Year!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Code:
    myValue VAR BYTE
    myValue = 255 - myValue
    Now, if myValue is 0 you'll get 255, if myValue is 255, you'll get 0.

    /Henrik.

  3. #3
    Join Date
    Aug 2008
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Working!

    Thanks Henrik, I guess I shouldn't have slept through math class. Your the man!.

  4. #4
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Why don't you reverse the connections to the pot?
    /
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

Members who have read this thread : 1

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