EMBEDDED TOOL

Arduino map() Function Calculator

Compute map(value, fromLow, fromHigh, toLow, toHigh), truncation included.

map() result (integer, as Arduino computes it)

Exact (unrounded) value

Generated code

About this tool

Work out what Arduino's map(value, fromLow, fromHigh, toLow, toHigh) function will return, without flashing a sketch just to check — including the integer truncation Arduino actually applies, which can catch people off guard compared to a "clean" proportional result.

Frequently asked questions

Why is the integer result different from the exact value?
Arduino's map() uses integer (long) arithmetic internally and truncates toward zero rather than rounding — so a mathematically exact result of 127.8 becomes 127, not 128. This tool shows both so you can see exactly what your sketch will get.
Does map() constrain the output to the target range?
No — if value falls outside [fromLow, fromHigh], the result can fall outside [toLow, toHigh] too. Wrap the call in constrain() if you need the output clamped to the target range.
Can fromLow be greater than fromHigh (or toLow greater than toHigh)?
Yes — map() supports reversing a range this way (e.g. mapping 0–1023 to 255–0 to invert a value), and this calculator handles that correctly too.