When is Inversion helpful/useful?

Ive been going through the examples and tutorials one at a time, and several have lines that store variables as inversions. They are just short snippets of code, so it doesn't explain why/what applications inversions would be useful for.

that store variables as inversions.

Can you give an example, I don't know what you mean.

Can you give an example, I don’t know what you mean.

Took me a minute to find the example I was working.


In particular, this bit of code.

int ReadSens_and_Condition(){
  int i;
  int sval = 0;

  for (i = 0; i < 5; i++){
    sval = sval + analogRead(0);    // sensor on analog pin 0

  sval = sval / 5;    // average
  sval = sval / 4;    // scale to 8 bits (0 - 255)
  sval = 255 - sval;  // invert output
  return sval;

Thats because common anode leds will be full on with an analogWrite() value of 0, and common cathode leds will be full off with that same value, so maybe its just a thing of adjusting the code to cope with the available hardware.

Thanks! After reading some more and experimenting, I can see where it can be used for things like my h-bridge, which takes 2 signal lines and uses 2.5v as motor off and 0 as full reverse and 5v/255 as full forward. I was trying to code for it and realized inversion was exactly what I needed.