Data Sheet

Project 17
Light Controlled LED
Build the circuit and load sketch Light_Controlled_LED into Snapino
TM
using the programming instructions in project 3. Vary the brightness of
light on the phototransistor (Q4) to change the brightness of the red
LED (D1). The red LED gets brighter as the phototransistor gets darker.
The circuit acts as a night light, making the red LED brighter as the
room gets darker.
Programming Note:
The light on the phototransistor is measured with the
analogRead
() command, then 1/16 of that value is
used for the red LED brightness with the
analogWrite() command. The value is divided by 16
because analogRead() returns a number between
0 and 1023 while the analogWrite() value must be
between 0 and 255, and because the red LED will
appear to be near full brightness for values >30.
-27-
SCSNAPINO_Manual_112816.qxp 12/30/16 2:00 PM Page 28