Data Sheet

Guide V1.0
Email: keen@elecrow.com Web: www.elecrow.com ---Designed by Elecrow Keen
24
Compile and upload
Tips: Refer to the operation demo (Step4 to Step8).
Language reference
Tipsclick on the following name to jump to the web page.
If you fail to open, use the Adobe reader to open this document.
digitalWrite()
analogRead()
Application effect
By turning the shaft of the potentiometer, you change the amount of resistance on either
side of the center pin (or wiper) of the potentiometer. This changes the relative resistances
between the center pin and the two outside pins, giving you a different voltage at the analog
input. When the shaft is turned all the way in one direction, there is no resistance between
the center pin and the pin connected to ground. The voltage at the center pin then is 0 volts,
and analogRead() returns 0. When the shaft is turned all the way in the other direction,
there is no resistance between the center pin and the pin connected to +5 volts. The voltage
at the center pin then is 5 volts, and analogRead() returns 1023. In between, analogRead()
returns a number between 0 and 1023 that is proportional to the amount of voltage being
applied to the pin.
That value, stored in sensorValue, is used to set a delay() for your blink cycle. The higher
the value, the longer the cycle, the smaller the value, the shorter the cycle. The value is
read at the beginning of the cycle, therefore the on/off time is always equal.
Lesson 5: Fading
Overview