Map
Remaps the specified value from one range to another. This function
maps the value of from low to the value of to low, the value
of from high to the value of to high, and intermediate values
to intermediate values.
This function does not constrain values to the ranges, because
out-of-range values are sometimes intended and useful. If you need to
limit a range, you can use the Math.clamp function before or after
calling this function.
pins.map(0, 0, 4, 0, 1023);
Parameters
value: a number that specifies the value to mapfromLow: a number that specifies the lower bound of the origin intervalfromHigh: a number that specifies the upper bound of the origin intervaltoLow: a number that specifies the lower bound of the target intervaltoHigh: a number that specifies the upper bound of the target interval
Example
This example maps the value read from the analog pin P0 to an LED
coordinate between 0 and 4.
let value1 = pins.analogReadPin(AnalogPin.P0)
let index = pins.map(value1, 0, 1023, 0, 4)
led.plot(0, index)