Light sensor
A light-dependent resistor, with a slider for how bright the room is.
- 2 pins
- 3 properties
Every one of its 2 pins
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 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.
On a 3.3 V board, run the divider from 3.3 V and scale the thresholds to its ADC range.
The 3 properties you can set
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.
See the Light sensor in a project
Shown here on: Arduino Uno R3
Where it turns up in a lesson
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Light sensor
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.