Arduino MapFloat Library Documentation




I have always used the Arduino IDE map function but have not been able to use it for float values. With these I have made the MapFloat Library so that I could extend the map function to floating point numbers.

A very useful feature when I want to have decimal places on my map function.


Introduction

A library that contains the mapFloat function which re-maps a floating point number from one range to another. The mapFloat function is inside the MapFloat library.

This library is based on the Arduino Map Function.

Here is a link to the reference of Arduino Map Function.
https://www.arduino.cc/reference/en/language/functions/math/map/

Installing the MapFloat Library

Download the MapFloat Library from RadishLogic’s Github repository.
https://github.com/radishlogic/MapFloat

Clone or Download >> Download ZIP. This will download the file MapFloat-master.zip.

Unzip the MapFloat-master folder inside the zip file and paste it on the library folder where your Arduino IDE is installed.

Rename MapFloat-master folder to MapFloat only.

Restart your Arduino IDE.





Using the mapFloat function

Once you have installed the MapFloat Library you may now use the mapFloat function on your code as long as you add #include “MapFloat.h” at the top of your code.

Note: the MapFloat Library only contains a function. No instantiation of a class needed.

 

The mapFloat function also acts like the Arduino map function but can handle floating point numbers.

Function name: mapFloat

Parameters:

  • value (float)
  • fromLow (float)
  • fromHigh (float)
  • toLow (float)
  • toHigh (float)

Return: float – re-mapped value.


Example

This .ino file can be accessed in Arduino via File >> Examples >> MapFloat >> MapFloatExample.


I hope this Library helps on your projects.

If there are any errors, questions or suggestions that you can give me about the mapFloat library kindly comment below or send me a message via our contact page.




2 thoughts on “Arduino MapFloat Library Documentation”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.