When it is in steps of 20 ...
And you have 3 frames (zero index)
Then ... AnimationFrame = Max ( floor(value/20) , 2 )
When you want to spread a range over 3 frames ....
AMax = Maximum allowed analogue number.
AMin = Minimum analogue number.
ACur = analogue number at this moment.
AMax - AMin = Range .. Now lets normalise those with as rule that Amax should return the value 2 (zero based)
Ratio = 3 / Range
Norm = Ratio * Acur
Norm = (3/Range) * (ACur)
Norm = (3/ (AMax - AMin) ) * (ACur)
This returns numbers with decimals, animation frame will not take numbers with decimals, so we have to round that number.
AnimationFrame = Floor(Norm)
AnimationFrame = Floor((3/ (AMax - AMin) ) * (ACur))