Data Sheet
Programming Note:
This sketch uses a counter to increase the
brightness of the LEDs. Once the LED nears full
brightness then the counter decreases to make
the LEDs dimmer.
Some of the digital pins (including D9, D10, and
D11, which are connect to snaps and used here)
may be controlled using the analogWrite
()
command. analogWrite() simulates an analog
voltage using pulse width modulation, which
varies the duration of a digital pulse. Here the
LEDs are made brighter by increasing the
duration of the pulse (making the LEDs on for a
longer amount of time), or made dimmer by
decreasing the duration of the pulse.
The value for analogWrite
() can be from 0 (LED
off) to 255 (LED always on). This sketch uses a
maximum value of 30 for analogWrite(), because
the LED brightness would change very slowly for
higher values. Try increasing this value from 30 to
255, upload the sketch to Snapino
TM
, and see how
it affects the LED brightness. You can also adjust
the delay value (currently 30) to make the LED
brightness change faster or slower.
Why do analogWrite
() values of 30 or more make
the LEDs appear at full brightness? Because the
light is changing faster than your eyes can adjust,
and your eyes continue seeing what they have
just seen. This is often called “persistence of
vision”. This concept is used in movie theaters.
Project 16
Varying LED Brightness
Build the circuit and load sketch
Varying_LED_Brightness into Snapino
TM
using
the programming instructions in project 3. The
three LEDs (D1, D2, & D10) continuously vary in
brightness.
-26-
SCSNAPINO_Manual_112816.qxp 12/30/16 2:00 PM Page 27










