The programming library available with the Arduino has an interesting interpolation function, the

**map**function. Sadly, it returns only integers. As you might want to interpolate floating point numbers for some instrumentation routine, for example, the integer limitation may lend you into some low resolution results.
Fortunately, Arduino supports method overloading, and we can rewrite another

**map**function to support floating point numbers.
The new

**map**function could be like this:**float map(int x, double in_min, double in_max, double out_min, double out_max){**

**return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;**

**}**

## Comments

## Post a Comment