Hardware Reference
In-Depth Information
Example
void setup() {
// The code here will be executed once
// when the board is booted.
}
void loop() {
// The code here will be executed
// repeatedly after setup() is executed.
}
map
Scales a value from one range of numbers to another. See “map()” on page
81 .
Syntax
map(input, inFrom, inTo, outFrom, outTo)
Parameters
input
The input value to be scaled
inFrom
The first number in the input scale
inTo
The second number in the input scale
outFrom
The first number in the output scale
outTo
The second number in the output scale
Return value
map() returns a value on the scale of outFrom to outTo .
Example
sensorReading = analogRead(0);
int displayValue = map(sensorReading, 0, 1023, 0, 100);
Given an input value from analog pin 0, which is on the scale of 0 to 1023,
store a new value on the scale of 0 to 100. So if sensorReading were 256,
displayValue would be 25.
Search WWH ::




Custom Search