Some have you might have noticed that the extremely helpful map() function in arduino cannot cope with floated values. Since we really needed this functionality I wrote a mapFloat() function (or actually simply adapted the existing function), which accepts floated values and outputs a floated value as well. Keep in mind that the range of the numbers you can use is smaller (in integer), so don’t use extremely large values and only use this if you require a floated value. I use this to map ledvalues from a range 0-255 to a range 0-1 (which is useful in many cases!).
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}





