# Converting Ranges

I am writing a program for the arduino that takes a number as input and displays colors based on that input. At any given time, I know the value of the variables min and max where min is the minimum value of the input range and max is the maximum value of the input range. The problem is, in order for my program to work I have to convert this range to a range of 0-80. Is there a mathematical equation I can use for this?

-

Denote min and max by $m$ and $M$ and use
$$f(x) = 80\cdot \frac{x-m}{M-m}$$
Then, $f$ proportionally maps the interval $[m,M]$ to $[0,80]$ as you asked. (In other words, as $x$ moves from $m$ to $M$, if it covered $a\%$ of the interval $[m,M]$, the result, $f(x)$ will have covered $a\%$ of the resulting interval $[0,80]$.