Arduino Lab 7: Night Light
Background: Patients may need to get around their room at night, so having an automated nightlight system can be helpful.
Goal: Using a photocell, turn on an LED when it gets dark.
Circuit Setup
- Materials
- 1x Arduino
- 1x Photocell
- 1x LED
- 1x 220 Ohm resistor
- 1x 10k Ohm resistor
- Setup
- LED - connect the LED to digital pin 2 via 220 Ohm series resistor as we've done previously.
- Connect photoresistor between 5V and A0.
- Connect 10 kOhm resistor between A0 and GND.

Lab Instructions
- Detect the ambient brightness with a photocell. Turn on the night light (external LED) if it gets too dark.
- Use Serial.println() to print analogRead() values. Block the light and determine a good threshold value.
- Once the value is below the threshold, turn on the LED.
- Stretch Goal: Look up how to use analogWrite() to control the brightness of the LED in the components section.