Solutions to inverting results

Hi … kindly guide me on how to implement this on my code. My result from my duty are correct but I want to inverse the signal such that when having high value, my output will be low value. Like this

Original result 0-255, but I want to make use of it such that 0 will be 255 and 255 will be 0. How can I implement this please :pray:. Thanks

byte old_value = 255;
byte new_value = 255 - old_value;

Thanks

I use the bitwise not. ~ - Arduino Reference Be sure to read the Notes and Warnings. This works on all numbers I think except floating point.

...but don't forget to mask-off the unused bits.