How to stop/do something if analog value has not changed in a certain amount of time

Hello
You can use this simple function template for your project:

template<typename T>
T map(T x, T in_min, T in_max, T out_min, T out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Have a nice day and enjoy coding in C++.