chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko

Map

  1. Synopsis

  2. Description

  3. Return Value

  4. Conforming To

  5. Examples

  6. See Also

Synopsis

 long map(long x, long in_min, long in_max, long out_min, long out_max)

Description

The map() function takes a value x which is in the range in_min <= x <= in_max and calculates the corresponding value y in the range out_min <= y <= out_max. The resultant value is proportionally the same within the new range.

Return Value

The proportionally equivalent value of the input.

Conforming To

map() conforms to the Arduino 1.6.x API.

Examples

Map the value 5 in the range 0-10 to the value 10 in the range 0-20. 5 is 50% of the range 0-10 and 10 is 50% of the range 0-20.

 int in = 5;
 int out = map(in, 0, 10, 0, 20);

See Also

random(), randomSeed()