EasyManua.ls Logo

SunFounder 3in1 Kit - Page 154

Default Icon
351 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder 3in1 Kit
Code
Note:
Open the 5.6.map.ino file under the path of 3in1-kit\learning_project\5.6.map.
Or copy this code into Arduino IDE.
After the code is uploaded successfully, you can rotate the potentiometer back and forth, and the output shaft of the
servo will rotate back and forth.
How it works?
map(value, fromLow, fromHigh, toLow, toHigh): Map a number from one range to another. That is, a from-
Low value is mapped to toLow, and a fromHigh value is mapped to toHigh.
Syntax
map(value, fromLow, fromHigh, toLow, toHigh)
Parameters
value: the number to map.
fromLow: the lower bound of the value’s current range.
fromHigh: the upper bound of the value’s curr+ent range.
toLow: the lower bound of the value’s target range.
150 Chapter 4. Basic Projects

Related product manuals