Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ARDUINO: MAP FLOAT FUNCTION
double mapf(double val, double in_min, double in_max, double out_min, double out_max) {
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@Kerlenton

This comment has been minimized.

Copy link

@Kerlenton Kerlenton commented Aug 20, 2019

hello, for what using this function?

@nadavmatalon

This comment has been minimized.

Copy link
Owner Author

@nadavmatalon nadavmatalon commented Aug 20, 2019

Hi,

I wrote this a long time ago but as best I remember this function maps a given double-type number from one range onto another range. So for example, if you give it the number 5, input range of 1-10, and output range of 1-20 it will return 10.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment