T ThinkEdge Learn

Arduino LDR light sensor projects

An LDR turns light into a voltage — here it switches on a night light, follows the sun, wakes a room up and builds a sundial.

7 projects Easy first Arduino uno, Arduino mega

An LDR is a resistor whose resistance falls as the light on it rises, and the Arduino reads that through a voltage divider. There is no digital output, no protocol and no timing — it is the simplest possible analogue sensor, and it is the best first one for a class that has never used analogRead.

The projects here use it in four ways: as a switch (it is dark, turn the light on), as a comparator (which of the two LDRs is brighter), as a level (how much light is there now) and as a clock (how long has the light been changing). That last one is the most interesting and the hardest, and it is what the smart sundial does.

What you need

The parts below are the ones the most of these projects share. Each project page lists the full set for that build.

PartUsed byWhy
1× 220Ω resistor4Limits the current through an LED or a pin
Breadboard3Holds the circuit together without solder
1× breadboard3Holds the circuit together without solder
1× 9V battery3The supply the circuit runs on
8× jumper wires3The wires that join it up
1× 10kΩ resistor3Sets how much current flows

All 7 arduino ldr light sensor projects

Easiest first. Each card links to the project's own page with the wiring, the parts and the code written out.

Arduino — Light-Activated Night Lamp

LDR + LED — the LED turns on automatically when it gets dark

Tier 1 · Basics · Easy · 20 min
LDR — Automatic Night Light

The room gets dark, the LED turns on

Tier 2 · Logic & Sensors · Easy · 25 min
LDR — Sunrise Alarm Clock

When the sun rises, the room wakes up with a soft glow

Tier 3 · Combined Projects · Intermediate · 30 min
Smart Sundial

A light sensor that tells the time of day

Tier 3 · Combined · Intermediate · 35 min
LDR — Light-Following Robot (Solar Tracker)

It always faces the brightest spot

Tier 3 · Combined Projects · Advanced · 50 min
Arduino Mega — Multi-Sensor Data Hub

Read 3 sensors at once and stream them to the Serial Monitor

Tier 3 · Combined Projects · Advanced · 40 min
Arduino — Solar Tracker with Two LDRs

A servo that follows the light, like a real solar panel

Tier 3 · Combined Projects · Advanced · 45 min

How to use these with a class

These 7 projects run from about 20 minutes to 50 minutes each, and 1 of them are Tier 1 — one component and one idea, which is what a class can finish in a single period.

Each project page carries the full build — the concept, the parts, the wiring one step at a time and the sketch — so a class can work through it without the teacher having to explain every wire.

Every one of them can be practised in the browser simulator first, with the real sketch and a real circuit solver behind it, and the first 15 projects are free with no account.

Common questions

What is the other resistor for?

The LDR needs a partner to make a voltage divider. The two sit in series across 5 V, the Arduino reads the midpoint, and the reading changes as the light changes. Without the second resistor the pin has nothing meaningful to read.

Why does the reading not reach 0 or 1023?

Because a real LDR never gets that extreme. The values depend on the particular resistor, the ambient light and the voltage — which is why the projects compare against a threshold rather than looking for a fixed number, and why the threshold has to be tuned in the room the circuit is in.

Can I use a photoresistor instead?

A photoresistor is the same thing under a different name, and it drops straight in. The project pages say "LDR (photoresistor)" for exactly that reason.

Related

All the projectsThe complete catalogue The guidesHow the ideas behind these work Arduino projects for beginnersThe board-specific builds Arduino simulator in the browserTry any of these without hardware

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.