Arduino — Light-Activated Night Lamp
LDR + LED — the LED turns on automatically when it gets dark
Arduino
LDR
Photoresistor
analogRead
What you will learn
- How a voltage divider works (two resistors between 5V and GND, read from the middle)
- Why we need a fixed 10kΩ resistor in series with the LDR (the Arduino cannot read a resistor alone)
- How to use analogRead() to get a brightness value, and map() to convert it to LED brightness
What you will need
| Component |
|---|
| 1× Arduino Uno R3 |
| 1× LDR (photoresistor) |
| 1× 10kΩ resistor |
| 1× LED (yellow) |
| 1× 220Ω resistor |
| 1× breadboard |
| 5× jumper wires |
Step by step
Take it further
- Add a button to toggle the lamp on/off manually (so you can force it on during the day).
- Use PWM to make the LED brightness PROPORTIONAL to darkness (dim in twilight, full bright in pitch black).
- Add a second LED of a different color that turns on when it is BRIGHT (a "daylight indicator").
Practise it before you build it
Wire this circuit in the ThinkEdge Learn simulator first. The simulator runs a real Arduino sketch against a modified-nodal-analysis solver, so the LED on screen actually lights when the current is right — no hardware, no burnt components, and a class can try it in a browser.
Related projects
Arduino — Blink Without DelayUse millis() instead of delay() — the right way to blink
Arduino — Fade an LED with PWManalogWrite on D9 — the smoothest way to dim an LED
Arduino — Button + Buzzer DoorbellPress the button, hear a tone. The classic Arduino starter.
Arduino Nano — Temperature on Serial MonitorRead the room temperature every 2 seconds and print it
Arduino — LED Chaser (Knight Rider)5 LEDs that light up in sequence, like KITT from Knight Rider
LDR — Automatic Night LightThe room gets dark, the LED turns on
Guides that use this project
6 guides on the site build this project as part of a longer explanation. The guide says why the circuit works; this page says how to wire it.
Robotics for BeginnersRobotics for beginners: five projects that take you from a blinking LED to a robot that steers itself, with the parts and the mistakes at each step.
Arduino Projects for BeginnersTen Arduino projects for beginners that really work, in the order that makes them easiest, with the parts each one needs and the mistake that catches people out.
Solar and Renewable Energy ProjectsSolar and renewable energy projects for students: a light tracker, a solar water heater, a wind generator and a home energy monitor, with the physics behind each.
Solar-Powered DevicesHow to build a solar-powered device: charge controllers, energy budgets, why a panel alone is not enough, and how to size everything for a sensor that runs all year.
How to Learn ArduinoHow to learn Arduino properly: an eight-week plan from a blinking LED to real builds, with the parts to buy first and the mistake that slows most beginners down.
arduino.cc and the Official Arduino Resourcesarduino.cc is the official Arduino site: the language reference, the board specs, the library registry and the free learning resources worth using in class.
Where this project sits
It is also part of these lists, which is how a class usually finds it.
Arduino LED projects for beginners36 projects in this list
Arduino LDR light sensor projects7 projects in this list
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. One licence covers a whole school.