Intel® Edison Hands-on Day 3: Light dimmer

Light dimmer
Light dimmers are devices used to vary the brightness of a light. Through a rotation sensor, we can tune the intensity of the light output. More you rotate the knob, the brighter the LED will be. So let’s try to make a dimmer by ourselves.
Rotation sensor can be applied in various kinds of application, such as the servo controlling, DC motor speed controlling and etc.

Analog Rotation Sensor acts as an input device, while the PWM output controls the brightness of the LED

Coding review

Let’s talking about the map() function
This is the format of the map() function?map(value, fromLow, fromHigh, toLow, toHigh)
Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.

Parameters of map()?
value?the number to map
fromLow?the lower bound of the value's current range
fromHigh?the upper bound of the value's current range
toLow?the lower bound of the value's target range
toHigh?the upper bound of the value's target range

Note that the "lower bounds" of either range may be larger or smaller than the "upper bounds" so the map() function may be used to reverse a range of numbers, for exampley = map(x, 1, 50, 50, 1);