long map(long x, long in_min, long in_max, long out_min, long out_max)
The map() function takes a value x which is in the range in_min <= x <= in_max and calculates the corresponding value y in the range out_min <= y <= out_max. The resultant value is proportionally the same within the new range.
The proportionally equivalent value of the input.
map() conforms to the Arduino 1.6.x API.
Map the value 5 in the range 0-10 to the value 10 in the range 0-20. 5 is 50% of the range 0-10 and 10 is 50% of the range 0-20.
int in = 5;
int out = map(in, 0, 10, 0, 20);