All projects

Sensors

Automatic night light

Beginner20 min

A light that turns itself on when the room gets dark, using a light-dependent resistor.

What you get

An LED lighting up below a brightness threshold, adjustable and free of flicker.

Parts (simulated)

  • Arduino UNO board
  • Light sensor (LDR)
  • 10 kΩ resistor
  • 5 mm LED
  • 220 Ω resistor

Nothing to buy: every component here is simulated in the browser.

Project steps

  1. 01Wire the LDR as a divider into the analog input.
  2. 02Read the raw value and print it on the serial monitor.
  3. 03Pick a trigger threshold from the measurements.
  4. 04Add hysteresis so the LED doesn't flicker at the threshold.

What you learn

  • Voltage divider
  • Analog-to-digital conversion
  • Threshold and hysteresis

Other projects