Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.
Name | map() |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Examples | int value; int m; void setup() { Serial.begin(9600); } void loop() { value = analogRead(0); m = (int)map(value, 0, 222, 0, 100); // converts a number in the range Serial.println(m); // 0-255 to a number in the range 0-100 delay(100); } |
||||||||||
Description | Re-maps a number from one range to another. In the example above,
the number value is converted from a value in the range 0..255 into
a value that ranges from 0 to 100.
Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. |
||||||||||
Syntax | map(value, low1, high1, low2, high2)
|
||||||||||
Parameters |
|
||||||||||
Returns | float | ||||||||||
Usage | Application |