Average of reading on IR sensor

robtillaart:
...
I mostly use something like this

void loop() 

{
  x = x - 0.15 * (x - analogRead(PIN) );  // 0.15 can be any value between 0.001 and 1.0
}



...

I like that :slight_smile:

Is there a way of changing the formula so it calculates in int instead of float?