Data Sheet
28 : circuit 1c
WHAT YOU
SHOULD SEE
The program stores the light level in
a variable. Using an if/else statement,
the variable value is compared to the
threshold. If the variable is above the
threshold (it’s bright), turn the LED off.
If the variable is below the threshold (it’s
dark), turn the LED on. Open the Serial
Monitor in Arduino. The value of the
photoresistor should be printed every so
often. When the photoresistor value drops
below the threshold, the LED should turn
on (you can cover the photoresistor with
your finger for testing).
NEW IDEAS
LIGHT LEVELS: If the room you are in is very bright or dark, you may have to change
the value of the
threshold variable in the code to make your night-light turn on and
off. See the Troubleshooting section for instructions.
PROGRAM OVERVIEW
1
Store the light level in the variable photoresistor.
2
If the value of the photoresistor is above the threshold (it’s bright), turn the LED off.
3
Otherwise, the value of the photoresistor is below the threshold (it’s dark), turn the LED on.
Open the Arduino IDE
Connect the RedBoard to a USB port on your computer.
Open the Sketch:
File > Examples > SIK_Guide_Code-V_4 > CIRCUIT_1C-PHOTORESISTOR
Select UPLOAD to program the sketch on the RedBoard.