map() \ Language (API) \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

Reference for Wiring version 0023+. If you have a previous version, use the reference included with your software. If you 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, 1023, 0, 255); // converts a number in the range
      Serial.println(m, BYTE);              // 0-1023 to a number in the range 0-255
      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..1023 into a value that ranges from 0 to 255. 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 |
value | float: The incoming value to be converted
low1 | float: Lower bound of the value's current range
high1 | float: Upper bound of the value's current range
low2 | float: Lower bound of the value's target range
high2 | float: Upper bound of the value's target range
Returns | float
Usage | Application

Updated on November 01, 2009 12:47:23pm PST