What it is
A model street-lighting system. An Arduino reads ambient light from an LDR, decides whether it's dark enough, and switches a row of LED lamps on or off through a MOSFET. The whole rig runs off a single 12V supply.
Why I built it
Timer-based street lights are wasteful. They turn on too early in summer, too late in winter, and don't react to overcast days at all. A light sensor solves that with about twenty extra cents of hardware. I wanted to prove to myself — and to anyone looking — that the "smarter" version is genuinely simpler than people think.
What's inside
- Arduino Nano running the main loop at a relaxed 1 Hz (no need to spam the ADC).
- LDR in a voltage divider feeding analog input A0.
- IRLZ44N logic-level MOSFET switching the lamp rail.
- Three parallel LED lamp heads, current-limited per head.
- 12V → 5V step-down for the Arduino.
What I learned
Hysteresis is the difference between a working sensor system and a flickering one. My first version used a single threshold — as soon as the light level crossed it, the lamps switched. At dusk, clouds rolling past would trigger the lamps on and off every few seconds. Adding a two-level threshold (turn on at 380, turn off at 460) fixed it immediately.
I also learned that analog readings are noisier than they look. A rolling average of the last 10 samples smoothed things out without adding any real lag — the sun doesn't set in a second.
What I'd do differently
I'd add a real-time clock as a sanity check. If the sensor fails or gets covered (a leaf, a bird, a cheeky hand), the system has no fallback. A clock would at least let it default to sensible behavior based on time of day.