Simple Invert Question

Hi I am trying to invert a 0-255 analogue signal but having trouble. I know this is really simple I have just completely forgot and would appreciate any help. The analogue button increase as it slides towards me but want it to increase as it slides away from me

I tried the ~ method but does not seem to work

int button

data[0] = constrain(button,0,255);

The usual solution is to use a value of 255 - n, rather than n, in the analogWrite() call.

PaulS:
The usual solution is to use a value of 255 - n, rather than n, in the analogWrite() call.

Thank you Paul. That works :slight_smile: