-
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!
-
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.
-
Working!
Thanks Henrik, I guess I shouldn't have slept through math class. Your the man!.
-
Why don't you reverse the connections to the pot?
/