Part

Light sensor

A light-dependent resistor, with a slider for how bright the room is.

or see every part
  • 2 pins
  • 3 properties
Drawn live by the editor's own code, at the size you see it.
Reference

Every one of its 2 pins

Pin
What it does
1
One leg.
2
The other leg.
This part

What it does

A light-dependent resistor, or photoresistor, is a resistor whose value depends on the light falling on it: under a thousand ohms in daylight, tens of kilohms in a room, and a megohm or more in the dark. It has no supply pin and no output, so it is always wired in a divider with a fixed resistor and a board reads the voltage in the middle. Mokxi’s part follows the GL5528 datasheet curve, resistance falling as a power of the light level, with a cap in full darkness, and all three numbers are properties, so a GL5537 is the same part with a different value at 10 lux. The light level is a slider on the part, in lux. It does not model the cell’s slow response, the twenty or thirty milliseconds a real one takes to follow a change, or its long recovery after bright light.

How to use it

How to use an LDR with an Arduino

An LDR needs a partner: put it between 5 V and an analog pin, and a 10 k resistor between that pin and GND. analogRead() then goes up as the light comes up. Pick the fixed resistor near the LDR’s own resistance at the light level you care about, and switch on two thresholds with a gap between them, so the output does not flutter at dusk.

Part pin
Board pin
LDR
5 V and A0
10 k resistor
A0 and GND

On a 3.3 V board, run the divider from 3.3 V and scale the thresholds to its ADC range.

Arduino Uno: night lightlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Reference

The 3 properties you can set

Property
Default
What it means
r10
15000
resistance at 10 lux, 15 000 ohms by default (a GL5528).
gamma
0.6
the slope of the resistance/light curve on log-log paper, 0.6 by default.
dark
1000000
the resistance cap in full darkness, 1 000 000 ohms by default.
How it is modeled

What is true about the Light sensor, here

What is modeled

The curve is the datasheet's own: R(lux) = r10 x (10 / lux) ^ gamma, capped at dark. With the GL5528 defaults that gives about 950 ohms in full daylight, 15 k in a dim room, 60 k by candlelight and the megohm cap with the window covered. A GL5537 is the same model with r10 set to 50 000, an order of magnitude up.

Not modeled

No response time. A real cell takes twenty or thirty milliseconds to follow a step and much longer to recover from bright light, the "light history effect" every datasheet apologizes for, but nothing here runs fast enough for that lag to be the thing that limits a circuit.

The power law is the datasheet's shape, not a fit to one cell: a real GL5528's gamma drifts across the range rather than staying at 0.6, and the part-to-part spread on r10 is a factor of two or more, so the ohms here are the right order and the right slope rather than a number to calibrate against. There is no noise, no temperature coefficient (a real cell moves several percent across a room's range), no spectral response (the slider is lux of some unspecified color), and no maximum voltage or power. The resistance changes the instant the slider does.

From LDR (light-dependent resistor), in full.

Projects

See the Light sensor in a project

Shown here on: Arduino Uno R3

Wire up the Light sensor

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.