Arduino automatic night light: LDR and a PWM LED
Open in the lab ▸Make my own copy
An LDR (light-dependent resistor) and a 10 kΩ resistor form a voltage divider: the brighter the room, the higher the reading on A0. The Arduino turns that into PWM on the LED, brighter as it gets darker, the way a garden or porch light dims up at dusk. Click the LDR and change the light. Open it and press Run: the sketch is inside the board (click the board, then Code). Every part, pin and resistor matches what you would build on a real breadboard; the guided build of the same name has the test sheet and hidden faults.
What is on the bench
6 parts, 8 wires, with a sketch (the program runs in the lab). Boards: Arduino Uno R3.
| Resistor | 2 |
|---|---|
| Arduino Uno R3 | 1 |
| USB charger / port | 1 |
| Photoresistor (LDR) | 1 |
| LED | 1 |
Put it on your page
The project runs live inside the frame: readers can press buttons, turn knobs and read the meters.
<iframe src="https://zencircuitlab.com/embed/zclcnight" width="100%" height="560" style="border:1px solid #2f363a;border-radius:10px" loading="lazy" title="Arduino automatic night light: LDR and a PWM LED on Zen Circuit Lab"></iframe>
Link
https://zencircuitlab.com/p/zclcnight
Published by its author under the lab's community terms: it may be opened, copied and changed by anyone. Simulation results are for learning; check a real build against the parts' datasheets.